http - Running Python through FastCGI with nginx on Ubuntu -


i've looked @ other threads on this, don't go enough setup detail need help.

i have ubuntu based vps running nginx, serving php sites through php-cgi on port 9000.

i'd start doing more python, i've written deployment script want use post-receive hook on local gitlab server first python script. can run script running python script.py on command line in order use post-receive hook need able access via http.

i looked @ this guide on nginx wiki partway down says to:

and start django fastcgi process:

python ./manage.py runfcgi host=127.0.0.1 port=8080

now, said pretty new python, , have never used django framework. can assit on how supposed start fastcgi server? replace ./manage.py name of script? appriciated i've found online refers working django.

do replace ./manage.py name of script?

no. it's highly unlikely script fastcgi server, or can accept http requests of kind since mention running on command line. (from little know of fastcgi, app supporting has able handle stream of requests coming in on stdin in specific format, there's plumbing involved.)

i'd easiest approach use some web framework act http/fastcgi middleware. use "microframework" flask (or paste found documentation inscrutable) sounds it'd work fine. idea have 2 interfaces main code, 1 can handle command line arguments, , 1 can handle http request, both call 1 function work. (if want keep command-line version of app.)

the flask documentation mentions using uwsgi or standalone workers deployment options. i'm not familiar former; the latter wouldn't recommend simple, low-traffic app same reasons approach in next paragraph.

considering use vps, might able run app standalone server process using the http.server module, i'm not sure that's better choice unless absolutely want avoid using sort of framework. you'd have make sure app starts if server rebooted or restarts when crashes , seems easier have nginx job of supervisor.

update: scratch that, seems nginx won't handle supervising fastcgi worker process you, would've been main advantage of approach. in light of doesn't matter of 3 approaches use since you'll have set service supervisor 1 way or other. i'd go uwsgi since flup (which needed flask+fastcgi) seems abandoned since 2011, , uwsgi protocol apparently supported in nginx natively. otherwise you'd need use different webserver nginx, 1 manage fastcgi worker you. if option, i'd consider cherokee, can configured using web gui.

tl;dr: need write (very simple) webapp. while feasible without web framework of kind, in opinion using 1 easier, since (nontrivial) plumbing free , there's lot of guidance available on how deploy them.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -