Search code examples
pyramiduwsgi

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?


Solution

  • 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.