Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

So I wrote this simple systemd service script:-

[Unit]
Description=uwsgi server script

[Service]
User=web
Group=web
WorkingDirectory=/var/www/prod/myproject/releases/current
ExecStart=/bin/bash -c 'source ~/.bash_profile; workon myproject; uwsgi --ini /var/www/prod/myproject/releases/current/myproject/uwsgi_prod.ini'

[Install]
WantedBy=multi-user.target

which works fine - it starts up and I can see my uwsgi processes in htop.

However, it inexplicably shuts down after being idle for 5 minutes.

If I start this process manually in bash console by executing, as web user:-

source ~/.bash_profile
workon myproject
uwsgi --ini /var/www/prod/myproject/releases/current/myproject/uwsgi_prod.ini

my process does not die after being idle.

What could the problem be?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Solved it after chatting with another dev on systemd channel.

Adding this into the [Service] section solved the problem:-

Type=forking
PIDFile=/tmp/project.pid-3030

The reason is simple. If Type isn't declared, the default is Type=simple, which expects the process does NOT fork so when bash exits, systemd thinks the process is dead and tears down the cgroup.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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