0

I know the new Ubuntu is more in favor of systemd than the upstart, but when I immigrate my website (python+nginx+uwsgi) from the Ubuntu 14.04, the upstart script is failed to launch during the system boot phase.

The upstart script is the same as the uwsgi docs:

# simple uWSGI script

description "uwsgi tiny instance"
start on runlevel [2345]
stop on runlevel [06]

respawn

exec uwsgi --master --processes 4 --die-on-term --socket :3031 --wsgi-file /var/www/myapp.wsgi

I am sure the nginx server is correctly configured, and the command (as follow) in the upstart script can serve the website normally in the shell (I can open the web pages from the browser).

uwsgi --master --processes 4 --die-on-term --socket :3031 --wsgi-file /var/www/myapp.wsgi

My question is how to make the upstart script work properly in Ubuntu 16.04.

foool
  • 101
  • 7

1 Answers1

1

I would create a systemd service to /etc/systemd/system/uwsgi.service. And disable the upstart script.

Maybe you will need to tweak the service script it a little bit, like the full path, user and After :

[Unit]
Description=uwsgi
After=network.target

[Service]
PIDFile=/run/uwsgi.pid
ExecStart=/usr/bin/uwsgi --master --processes 4 --die-on-term --socket :3031 --wsgi-file /var/www/myapp.wsgi
User=www-data
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Carl
  • 724
  • 3
  • 5
  • I think the upstart is still supported in 16.04, since the services in /etc/init can be loaded at the start-up, but I don't know what I missed. – foool Jan 05 '17 at 08:34
  • It should, but the service is a wrapper for systemd. – Carl Jan 05 '17 at 11:32
  • You missed that since 15.04 Upstart is not used at the system-wide level by default. Example: https://askubuntu.com/a/613785/43344 Upstart was still used at the per-user level. See https://askubuntu.com/a/613814/43344 . But even that was no longer the case as of Ubuntu 16, which you have also missed. See https://askubuntu.com/a/844045/43344 , https://askubuntu.com/a/844502/43344 , and others. – JdeBP Mar 06 '18 at 07:41