UWSGI

Instal┬Ělarem uWSGI (no al virtualenv)

pip install uwsgi

En el directory tasks tenim el wsgi.py i el ini d'exemple.

cd /home/INSTANCIA/tryton/
cp tasks/wsgi.py .
cp tasks/trytond-wsgi.ini /etc/trytond/.INSTANCIA-wsgi.ini
touch /var/log/trytond/INSTANCIA-wsgi.log

Ho podriem executar via comanda:

uwsgi --socket 127.0.0.1:3031 --chdir ~/virtualenv/try34galatea --protocol=http --wsgi-file wsgi.py --logto /tmp/mylog.log

Editem el fitxer trytond-wsgi.ini amb les nostres opcions.

Un exemple de fitxer wsgi.ini es:

[uwsgi]
# http://uwsgi-docs.readthedocs.org/en/latest/Options.html

main_path = /home/USER/tryton

http-socket = :8777
#~ https-socket = :8777,%(main_path)/projectes/tryton/cert/server.pem,%(main_path)/projectes/tryton/cert/server.key

# # store up to 20k sessions
# cache = 20000
# # 4k per object is enough for SSL sessions
# cache-blocksize = 4096
# # force the SSL subsystem to use the uWSGI cache as session storage
# ssl-sessions-use-cache = true
# # set SSL session timeout (in seconds)
# ssl-sessions-timeout = 30

#chdir = %(path)
virtualenv = %(main_path)
env = TRYTOND_CONFIG=%(main_path)/trytond.conf

file = %(main_path)/wsgi.py

master = True

processes = 4
threads = 2 
#enable-threads = true

#daemonize = %(path)/uwsgi.log
#pidfile = %(path)/uwsgi.pid

# It is a monitor (managed by the master process) that will destroy processes
#  stuck for more than the specified number of seconds.
# harakiri = 30

# Try to remove all of the generated file/sockets
vacuum = True

# uwsgi --connect-and-read %(path)/server.log1|2|...*processes
#py-tracebacker = %(path)/uwsgi_trytond.log

# uwsgitop :8010
#~ stats = :8010

logto = /tmp/trytond-wsgi.log

Arranc manual

Ara ja el prodriem arrancar amb la comanda:

uwsgi trytond-wsgi.ini

Supervisor

[program:trytond-wsgi_INSTANCIA]
command=/usr/local/bin/uwsgi /etc/trytond/.INSTANCIA-wsgi.ini
directory=/home/INSTANCIA/tryton
autostart=true
autorestart=true
stdout_logfile=/var/log/trytond/INSTANCIA_supervisord.log
redirect_stderr=true

Ara ja tenim el servei WSGI per arrancar amb supervisor.

Develop/UWsgi (last edited 2015-04-29 20:23:30 by resteve)

Contenidos creados por el equipo de Zikzakmedia. Creative Commons By-NC-SA

PythonZikzakmedia