0
  • Ubuntu 18.04 Server

I have multiple services running, that are all something like following template:

[Unit]
Description=projectA
After=multi-user.target

[Service]
WorkingDirectory=/media/deployment/deployment/projectA/src
User=userA
Group=userA
ExecStart=/media/deployment/scripts/projectA
Type=simple
Restart=on-failure
RestartSec=3
TimeoutStartSec=1
TimeoutStopSec=1

[Install]
WantedBy=multi-user.target

The script projectA looks like this:

#!/bin/sh
source /opt/venvs/projectA/bin/activate

cd /media/deployment/deployment/projectA/src
git pull

python3.7 -m pip install -r /media/deployment/deployment/projectA/requirements.txt

script -c "python3.7 main.py" -f "/media/deployment/logs/projectA.log"

Note: Every service has his own venv.

This works fine. However there is a reproducible bug:

If I restart one service sudo systemctl restart projectA every other service gets non responsive. Meaning that with systemctl status it says "active" and logs do not show any kind of error. However, as this services are mostly python flask apps, they simply do not respond on webrequests anymore. Also noticable: Non flask apps, like a Discordbot I host or just pure python scripts are working fine.

Is there something wrong with my configuration?

I used to have a smiliar setup on a Windows Server and there everything, including restarts, never seemed to effect anythingelse.


What I figured out: If I just systemctl stop the service, everything works fine. The "problem" occurres while (re)starting the service.

0

Try setting restart=always on all your services and RestartSec=3

  • Problem is that the service ( systemctl status ) seems to be running. However, the flask app does not respond to webrequests. – zaanposni Nov 29 '19 at 6:45
  • In that case culprit could be the type field.. Since you are calling a script via execstart and that in turn starts your flask application.. you may consider changing it to forking type and run the flask in the background.. and save it's pid in a file.. and in the unit file, point PIDFile="your pid file path" – Akash Sundaresh Nov 29 '19 at 6:53
  • Doing so, you'll be telling the systemd that it needs to monitor the process of the flask app and not that of the script that runs it.. – Akash Sundaresh Nov 29 '19 at 6:56
  • Did that. However, issue still remains. Flask app seems to be running. Simple curl requests gets declined and is not showing up in the stdout of my log file -> seems like the flask app completly freezes. Also I figured out: It is just that one service that is creating issues on startup. Every other service works fine. However, all those services were copy/paste and they work the same. – zaanposni Nov 30 '19 at 10:42
  • In that case I feel there's no issue with the systemd services.. Have u manually run these apps and tried to restart the projectA..?? If the problem is still seen its an issue with your apps... If not we'll be back to square one and the problem might really be with the systemd – Akash Sundaresh Nov 30 '19 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.