Using Flask, NGINX, and uWSGI I have setup successfully setup an app that I send and receive text messages through Twilio. Everything is working perfect, except that it is running under my personal user account (named trinitrogen). I'd like to move it to run off of a different user account(named apps) but am having trouble with the systemd unit file. The big crux of my difficulties, is I can't even find a good log of whatever the error is, so I'm not sure where to begin
First off, I based my work off this tutorial mostly had success with exactly what was shared
I created the new user and added it to wheel
[apps@argon ~]$ groups
apps wheel
Cloned the repo into apps home directory, setting up a virtualenv named venv inside the directory, installed all the python packages, successfully tested uwsgi in the command line
[apps@argon PowderMonitor]$ uwsgi --socket 10.0.0.221:8080 --protocol=http -w wsgi:app
It works great. I moved on to setting up the systemd file but this is where I've hit a wall. Below is the current file, along with the output after trying to restart the service.
[apps@argon PowderMonitor]$ cat /etc/systemd/system/TwilioApp.service
[Unit]
Description=uWSGI - TwilioApp - apps acccount
After=network.target
[Service]
User=apps
Group=nginx
WorkingDirectory=/home/apps/PowderMonitor
Environment="PATH=/home/apps/PowderMonitor/venv/bin"
ExecStart=/home/apps/PowderMonitor/venv/bin/uwsgi --ini TwilioApp.ini
[Install]
WantedBy=multi-user.target
[apps@argon PowderMonitor]$ sudo systemctl restart TwilioApp.service
[apps@argon PowderMonitor]$ sudo systemctl status TwilioApp.service -l
● TwilioApp.service - uWSGI - TwilioApp - apps acccount
Loaded: loaded (/etc/systemd/system/TwilioApp.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2017-04-14 16:35:52 CDT; 3s ago
Process: 3420 ExecStart=/home/apps/PowderMonitor/venv/bin/uwsgi --ini TwilioApp.ini (code=exited, status=1/FAILURE)
Main PID: 3420 (code=exited, status=1/FAILURE)
Apr 14 16:35:52 argon.xxx systemd[1]: Started uWSGI - TwilioApp - apps acccount.
Apr 14 16:35:52 argon.xxx systemd[1]: Starting uWSGI - TwilioApp - apps acccount...
Apr 14 16:35:52 argon.xxx systemd[1]: TwilioApp.service: main process exited, code=exited, status=1/FAILURE
Apr 14 16:35:52 argon.xxx systemd[1]: Unit TwilioApp.service entered failed state.
Apr 14 16:35:52 argon.xxx systemd[1]: TwilioApp.service failed.
[apps@argon PowderMonitor]$
Below is an example of the TwilioApp.service file that functions perfectly under my trinitrogen account. Notice that the only thing I've changed in the User, and the 3 directories
[trinitrogen@argon PowderMonitor]$ cat TwilioApp.service.example
[Unit]
Description=uWSGI instance to serve TwilioApp
After=network.target
[Service]
User=trinitrogen
Group=nginx
WorkingDirectory=/home/trinitrogen/Python/PowderMonitor
Environment="PATH=/home/trinitrogen/Python/PowderMonitor/venv/bin"
ExecStart=/home/trinitrogen/Python/PowderMonitor/venv/bin/uwsgi --ini TwilioApp.ini
[Install]
WantedBy=multi-user.target
Below is the TwilioApp.ini that is used for uwsgi, it is the exact same between the version i successfully ran under my "trinitrogen" account, and my "apps" account.
[apps@argon PowderMonitor]$ cat TwilioApp.ini
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = TwilioApp.sock
chmod-socket = 664
vacuum = true
#location of log files
logto = /var/log/uwsgi/TwilioApp.log
die-on-term = true