Jeremy T
Jeremy T

Reputation: 768

How do I stop a uWSGI server after starting it?

I have a Python pyramid application that I am running using uwsgi like so:

 sudo /finance/finance-env/bin/uwsgi --ini-paste-logged /finance/corefinance/production.ini

Once it's running and my window times out, I am unable to stop the server without rebooting the whole box. How do I stop the server?

Upvotes: 10

Views: 15269

Answers (2)

webjunkie
webjunkie

Reputation: 1184

If you add a --pidfile arg to the start command

 sudo /finance/finance-env/bin/uwsgi --ini-paste-logged /finance/corefinance/production.ini --pidfile=/tmp/finance.pid

You can stop it with the following command

sudo /finance/finance-env/bin/uwsgi --stop /tmp/finance.pid

Also you can restart it with the following command

 sudo /finance/finance-env/bin/uwsgi --reload /tmp/finance.pid

Upvotes: 9

Sergey
Sergey

Reputation: 12437

You can kill uwsgi process using standard Linux commands:

killall uwsgi

or

# ps ax|grep uwsgi
12345
# kill -s QUIT 12345

The latter command allows you to do a graceful reload or immediately kill the whole stack depending on the signal you send.

The method you're using, however, is not normally used in production: normally you tell the OS to start your app on startup and to restart it if it crashes. Otherwise you're guaranteed a surprise one day at a least convenient time :) Uwsgi docs have examples of start scripts/jobs for Upstart/Systemd.

Also make sure you don't really run uwsgi as root - that sudo in the command makes me cringe, but I hope you have uid/gid options in your production.ini so Uwsgi changes the effective user on startup. Running a webserver as root is never a good idea.

Upvotes: 14

Related Questions