these are the functions i use in my fabfile.py file (check out python fabric if you haven t already):
def start_uwsgi():
with cd(env.server.uwsgi):
if(exists( server.pid )):
stop_uwsgi()
run( sleep 1 )
run( source venv/bin/activate;uwsgi --ini uwsgi.ini; ))
def stop_uwsgi():
with cd(env.server.uwsgi):
if(exists( server.pid )):
run( source venv/bin/activate;uwsgi --stop server.pid; ))
In my uwsgi.ini file i specify:
[uwsgi]
socket = :{{your_port}}
master = true
vhost = true
no-site = true
processes = 1
enable-threads = true
pidfile = server.pid
daemonize = server.log
auto-procname = true
procname-prefix = servername_
for me the main gotyas were:
- use the daemonise option if you want to keep the uwsgi server going after you close your terminal/ssh session
- use vhost to run multiple sites under the same uwsgi instance, which is great if your bottleneck is memory, like mine is with the otherwise fantastic webfaction host
- pidfile tracks the current instance, enabling you to call uwsgi --stop pidfile, uwsgi --start pidfile
- procname and procname-prefix/append give a nice name to your process so you can easily single it out using ps -u username | grep some_string