python - Issue running uWsgi using pid/gid -
i'm trying run uwsgi using uid
/gid
parameters in wsgi ini file, drops privileged access after starting.
note: works fine expected when remove these 2 parameters ini file. also, there no issues socket. however, when run specified uid
, gid
(nginx user , group), error indicative of having problem virtual env loading,
traceback (most recent call last): file "wsgi.py", line 14, in <module> app import app application file "/var/www/wsgi/flask-appbuilder/peds_registry/app/__init__.py", line 1, in <module> import logging importerror: no module named logging
again, work fine when running without gid/pid. also, note user , group nginx both exist , both have ownership on python project's directory structure.
my nginx config's server/location directives follows:
server { listen 80; server_name hostname.domain; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name hostname.domain; ssl_certificate /etc/ssl/certs/host.chained.crt; ssl_certificate_key /etc/ssl/certs/host.key; ssl_protocols tlsv1 tlsv1.1 tlsv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'eecdh+aesgcm:edh+aesgcm:aes256+eecdh:aes256+edh'; location /test { include uwsgi_params; uwsgi_pass unix:/tmp/uwsgi.sock; } }
my uwsgi startup is:
#!/bin/sh # chkconfig: - 99 10 flask_home=/var/www/wsgi/flask-appbuilder export peds_home activate_cmd=/var/www/wsgi/flask-appbuilder/venv/bin/activate case "$1" in start) cd $flask_home source $activate_cmd uwsgi -s /tmp/uwsgi.sock -h ./venv/ --ini /var/www/wsgi/flask-appbuilder/test.ini --virtualenv /var/www/wsgi/flask-appbuilder/venv --chmod-socket=666 --manage-script-name --mount /test=run:app --wsgi-file wsgi.py --logto test.log & ;; stop) pkill uwsgi ;; restart) $0 stop $0 start ;; *) echo "usage: $0 (start|stop|restart|help)" esac
and uwsgi startup ini is:
[uwsgi] socket = /tmp/uwsgi.sock chdir = /var/www/wsgi/flask-appbuilder/peds_registry wsgi-file = wsgi.py pyhome = /var/www/wsgi/flask-appbuilder/venv callable = app manage-script-name = true mount: /test=run.py
as stated, loads fine without gid/uid parameters, when add
uid = nginx gid = nginx
to ini file, error noted above.
all searches yield permissions socket, problem seems loading modules within virtual environment.
on side note: using uwsgi installed pip virtual environment.
this not obvious. test, tried using own uid
/gid
run app, , lo' , behold, worked!
so, "i must have ownership on app uid
/gid
not have permission run" in mind, grepped venv on username, , voila answer appeared: 1 of requirements app needed run python 2.7.6, had installed per gist: python deployment. so, changing ownership of deploy
directory structure (which outside of venv's directory structure) app's user/group ticket.
Comments
Post a Comment