I'm trying to set up a simple uwsgi service named project
on Vagrant, Ubuntu 16.04.
It should start a simple Flask app that Nginx can talk to.
I can get the service to work when running
systemctl start project
, but can't get service to run after boot with systemctl enable project
.
Here is my project.ini
:
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = /tmp/project.sock
uid = ubuntu
gid = ubuntu
chmod-socket = 666
vacuum = true
die-on-term = true
logto = /tmp/project.log
Here is my /etc/systemd/system/project.service
:
[Unit]
Description=uWSGI instance to serve project
After=network.target
[Service]
User=vagrant
Group=vagrant
WorkingDirectory=/home/vagrant/flask_trial
Environment="PATH=.:/home/vagrant/bin:/home/vagrant/.local/bin:/home/vagrant/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini /home/vagrant/flask_trial/project.ini
[Install]
WantedBy=multi-user.target
Running systemctl status project
after boot yields:
Sep 12 05:26:08 vagrant systemd[1]: Started uWSGI instance to serve project.
Sep 12 05:26:09 vagrant systemd[1]: project.service: Main process exited, code=exited, status=1/FAILURE
Sep 12 05:26:09 vagrant systemd[1]: project.service: Unit entered failed state.
Sep 12 05:26:09 vagrant systemd[1]: project.service: Failed with result 'exit-code'.
Running journalctl | grep project
yields:
Sep 12 05:26:08 vagrant systemd[1]: Started uWSGI instance to serve project.
Sep 12 05:26:09 vagrant uwsgi[1123]: realpath() of /home/vagrant/flask_trial/project.ini failed: No such file or directory [core/utils.c line 3618]
Sep 12 05:26:09 vagrant systemd[1]: project.service: Main process exited, code=exited, status=1/FAILURE
Sep 12 05:26:09 vagrant systemd[1]: project.service: Unit entered failed state.
Sep 12 05:26:09 vagrant systemd[1]: project.service: Failed with result 'exit-code'.
I suspect one of two problems: file permisions, since google shows people often struggle to get these right, or path, since realpath() fails.
Permission for flask_trial
is
drwxrwxr-x 1 vagrant vagrant 272 Sep 12 04:50 flask_trial
For all files inside it:
-rwxrwxr-x 1 vagrant vagrant 185 Sep 11 02:59 main.py
-rwxrwxr-x 1 vagrant vagrant 189 Sep 12 04:50 project.ini
-rwxrwxr-x 1 vagrant vagrant 70 Sep 11 03:47 wsgi.py
I enable service with servicectl enable project
, without sudo
, so that user should be vagrant
.
Suspicious of path problem, as it looks like uwsgi can't findi project.ini, I tried modifying ExecStart to any of these:
ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini /home/vagrant/flask_trial/project.ini
ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini project.ini
ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini ./project.ini
None of above seems to work for boot, though all work for with systemctl start
. Really lost here and would appreciate some comments.