user1950164
user1950164

Reputation:

uWSGI does not start on startup

I have the following /etc/init/uwsgi.conf:

description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]
respawn

env UWSGI=/var/www/my_project/venv/bin/uwsgi
env LOGTO=/var/log/uwsgi/emperor.log

exec $UWSGI --master --emperor /etc/uwsgi/vassals --die-on-term --uid www-data --gid www-data --logto $LOGTO

As far as I can tell this is best practice as seen here

I also have /etc/uwsgi/vassals/my_project_uwsgi.ini:

[uwsgi]
#application's base folder
base = /var/www/my_project

#python module to import
app = server
module = %(app)

home = %(base)/venv
pythonpath = %(base)

#socket file's location
socket = /var/www/my_project/%n.sock

#permissions for the socket file
chmod-socket    = 666

callable = app

#location of log files
logto = /var/log/uwsgi/%n.log

processes = 10

Now, is it that uWSGI isn't being called on startup, or is it that there's something wrong with the overall config? (uWSGI config, nginx config, my app logic, file permissions etc?)

I think that the init script simply isn't being run. The reason why I think this is that when I run the init script manually, ie # /var/www/my_project/venv/bin/uwsgi --master --emperor /etc/uwsgi/vassals --die-on-term --uid www-data --gid www-data --logto /var/log/uwsgi/emperor.log then everything works as it should. On the other hand when I reboot the machine # reboot then nothing seems to happen. The uWSGI isn't running after reboot and more importantly, NOTHING is written on /var/log/uwsgi/emperor.log. From my experience with uWSGI, if you have a configuration mistake something is still written to emperor.log. So I conclude that /etc/init/uwsgi.conf isn't being run on startup.

How can I check this, and fix it?

EDIT: Update. tried sudo apt install upstart. Also this says that upstart needs inotify to detect changes in files in /etc/init, so I also did sudo apt install inotify-tools. However my script still doesn't run on startup.

Upvotes: 3

Views: 1570

Answers (1)

user1950164
user1950164

Reputation:

This solved it

apt install upstart-sysv

Inspired by this (Under "Permanent switch back to upstart)

Upvotes: 1

Related Questions