#django

/

      • moldy
        Koterpillar: what did he skip?
      • calq__ joined the channel
      • Jon_R
        sorry i didn't mean to skip anything, what did I miss?
      • Koterpillar
        oops, my bad, it's me who missed the dpaste. Jon_R: sorry!
      • Jon_R: nothing, sorry
      • Jon_R
        kk :-)
      • moldy
        Jon_R: you have --python-path in your systemd unit file right now? if you didn't do that yet, please run systemctl stop gunicorn; systemctl daemon-reload; systemctl start gunicorn
      • calq_ has quit
      • also, show us the updated gunicorn.service file
      • darylantony joined the channel
      • Jon_R
        ah that's a good point i've been reloading not restarting, 2 secs
      • programmerq joined the channel
      • FunkyBob
        gah
      • Jon_R
        it's --pythonpath not --python-path, 2 secs
      • moldy
        oh, right -- sorry
      • SamSagaZ_ joined the channel
      • Jon_R
        woohoo!
      • it works!
      • moldy
        good :)
      • FunkyBob
        I'll stick with uwsgi, thanks :)
      • koyaan joined the channel
      • Jon_R
        my systemd config now just says "/srv/wsgi/django/env/bin/gunicorn --env DJANGO_SETTINGS_MODULE=production.settings --pid /run/gunicorn/pid production.wsgi" , no pythonpath or anything
      • but it works :-)
      • which is what i had before, but now somehow it's different
      • FunkyBob
        pid files? really?
      • why?
      • moldy
        FunkyBob: does uwsgi make a big difference here? you don't have to specify the pythonpath there?
      • Jon_R
        because that's what the gunicorn documentation says to use
      • moldy> in uwsgi you just say virtualenv=/foo/env and job done
      • moldy
        oh. i actually like the gunicorn approach better, tbh.
      • Jon_R
        i'm trying to behave myself and do what I'm told as much as possible here :-)
      • FunkyBob
        well, you can install uwsgi in your venv
      • moldy
        FunkyBob: yes, that's what i do with gunicorn, too
      • FunkyBob
        however, uwsgi provides a LOT more than gunicorn
      • moldy
        but how does uwsgi detect the path to your django project root if you don't configure it?
      • FunkyBob
        moldy: that's nothing to do with venv
      • moldy
        FunkyBob: yes, that is why i wonder
      • FunkyBob
        that's a pythonpath issue, and you configure that
      • Jon_R
        haha now all i need to do is work out how to get nginx to behave
      • moldy
        alright, so this is the same :)
      • FunkyBob
      • moldy
        sure, uwsgi can do more, but if you don't need any of that, it doesn't matter. i also think that uwsgi does a little too much, maybe. matter of taste :)
      • FunkyBob
        I really need to put fragment links in this doc
      • moldy: yeah.. Graham Dumpleton has the same view :)
      • it's a bit like AWS... once you start using one thing, it tends to borg the rest of you
      • moldy
        i don't really enjoy it to take over maintainership of projects that are uwsi-only because they use their "cron" thing, for example
      • FunkyBob
        caching, spooling, and so much more :)
      • moldy
        uhh :p
      • pjs
        uwsgi cron thing?
      • FunkyBob
        yeah, it can run periodic tasks
      • moldy
        iirc i was told you can run periodic tasks with uwsgi
      • FunkyBob
        moldy: ws API, mules, offload workers...
      • pjs
        hah cool. I didn't even know that and I've used uwsgi forever
      • moldy
        so you don't need celery (which is nice), but now your app is bound to uwsi (not so nice)
      • ToApolytoXaos has quit
      • mattmcc
        Heh. We've actually got a project where uwsgi spawns the celery worker with attach-daemon.
      • FunkyBob
        oh, yeah, so don't need supervisord either :P
      • moldy
        i just use systemd :)
      • FunkyBob
        eww
      • moldy
        by now it's a good practice, imho
      • FunkyBob
        :P
      • moldy
        why should each app deploy its own process supervisor
      • and you get half-decent logging for free.. journalctl -u
      • FunkyBob
        oh, I agree... _no_ app needs to daemonise
      • moldy
        and the template thing can be used to get zero-downtime deployment relatively easily
      • pjs
        mattmcc: hah
      • Utal joined the channel
      • FunkyBob
        and if you move resource limit enforcement, duration control ,et c etc into the launcher's config, you're moving closer to mainfame OS territory :)
      • eieste has quit
      • moldy
        what i do is: have gunicorn.project_name@.service, where the tag is a timestamp. deploy the new code to a directory with a timestamp in the name, start the new service, rewrite the nginx config, wait a little, reload nginx
      • FunkyBob
        I did something similar for opensm ... the @ syntax is neat
      • barajasfab joined the channel
      • the way I configure nginx means I don't need to reconfigur it
      • moldy
        oh, how do you do that?
      • FunkyBob
        see my link ^^ :)
      • moldy
        will give it a read :)
      • darylantony has quit
      • though i probably need an nginx config change in some situations, because i also do fully-automatic letsencrypt :)
      • FunkyBob
        it's not quite what I use now... [many of my servers don't even use nginx now]
      • ah, yes...
      • moldy
        so i first deploy the app with ssl, then get the cert, then enable ssl
      • hamdjan has quit
      • *first deploy *without* ssl
      • Jon_R
        Sep 28 01:17:52 dexter gunicorn[31296]: message repeated 19 times: [ browser reported failure]
      • well that's a handy error message
      • FunkyBob
        look at the line before, Jon_R
      • Jon_R
        the line before is Sep 28 01:17:45 dexter gunicorn[31296]: browser reported failure
      • the line before that says "received unexpected data"
      • moldy
        i really think i should polish up my stuff, document it, support more distros, and then we could have a nice community-managed standard deployment script
      • FunkyBob
        +1
      • moldy
        https://github.com/plone/ansible-playbook the plone people did a nice job there
      • darylantony joined the channel
      • FunkyBob
      • Jon_R
        "uWSGI 1.9 (codenamed “ssl as p0rn”) added support for SNI (Server Name Identification) throughout the whole SSL subsystem. The HTTPS router, the SPDY router and the SSL router can all use it transparently."... why are they using pr0n as a codename, why are they doing SPDY...?
      • FunkyBob
        well, they do https2 now
      • in 1.9 it was still called spdy :)
      • hamdjan joined the channel
      • darylantony has quit
      • Jon_R
        yeah but uwsgi is wsgi why is it worried about http/http2/etc at all?
      • FunkyBob
        ... no, it's FAR FAR more than that
      • tdy joined the channel
      • darylantony joined the channel
      • besides, WSGI is just the back end... it needs a front end protocol to talk, right?
      • it does http, https, http2, uwsgi, fastcgi... and probably more
      • just like gunicorn talks http
      • Jon_R
        oh i thought it was a wsgi server you stuck a web server in front of
      • yeah that was a thing that worried me about gunicorn ;-)
      • FunkyBob
        well, sure, but it needs a protocol for other servers to pass it requests, right?
      • Utal has quit
      • Jon_R
        yes, wsgi?
      • FunkyBob
        wsgi is not a protocol
      • it's an API specification
      • an interface
      • the whole point of tools like gunicorn, uwsgi, waitress, etc...
      • is to publish WSGI apps
      • provide some protocol for requests to come in, and then hand them to the app
      • Jon_R
        ok so I now have no idea what "uwsgi_pass" does in nginx ;-)
      • moldy
        FunkyBob: where is the uwsgi_pass thing coming from?
      • FunkyBob
        moldy: ?
      • Jon_R: it tells nginx to pass requests to another server using the uwsgi protocol
      • Jon_R
        uwsgi is a protocol?
      • frewsxcv_
        uWSGI designed its own protocol, unrelated to WSGI or HTTP
      • ironfroggy joined the channel
      • Jon_R
        ah
      • here's me trying to avoid NIH syndrome and finding myself constantly the victim of other peoples' addiction to it ;-)
      • moldy
        FunkyBob: nginx has support for that built-in?
      • frewsxcv_
        browser <-- http --> nginx <-- uwsgi protocol --> uwsgi <-- python (using wsgi) --> your app
      • FunkyBob
        moldy: yep, just like it does for http and fastcgi
      • moldy
        FunkyBob: ah, i see. thanks.
      • ironfroggy has quit
      • frewsxcv_
      • moldy
        FunkyBob: and what does _ mean on that line? uwsgi_pass unix://srv/apps/_/server.sock;
      • Utal joined the channel
      • ironfroggy joined the channel
      • frewsxcv_
        or in my case: browser <-- http --> uwsgi <-- python (using wsgi) --> my app
      • FunkyBob
        moldy: it's a dir name?
      • # mkdir _
      • tuxtoti has quit
      • moldy
        FunkyBob: ah, so on update, you just remove that directory and create a new one?
      • FunkyBob
        ?
      • no?
      • moldy
        FunkyBob: i'm trying to understand how you do zero-downtime updates without changing your nginx config
      • FunkyBob
        deploy nwe code... touch uwsgi.ini in the app's dir
      • tlab joined the channel
      • moldy
        FunkyBob: ah, ok. i do things quite differently. on update i deploy a whole new virtualenv with its own gunicorn.
      • FunkyBob
        can do that
      • if you add another /*/ to the emperor search path you can have multiple copies of your code
      • and the one that runs is the one with a uwsgi.ini file
      • moldy
        hence i timestamp the whole directory, change the nginx config to point to the new one, reload nginx
      • FunkyBob
        the emperor discovers what to run by finding ini files