Debian 9 – rc.local deprecated, how to launch python at startup

fightstarr20 asked:

I am slightly lost, I have a Debian 9 server and a Python Flask script that I am trying to launch at startup.

In the past I have used rc.local to launch things at startup but from reading it seems that it is now deprecated.

Can anyone tell me what is its replacement, what method am I best using now?

My answer:


You launch it using a systemd unit, like every other service.

There are numerous tutorials out on the Internet about how to set this up. Or you can just start with a skeleton unit something like:

[Unit]
Description=uWSGI instance to serve my project
After=network.target

[Service]
User=you
Group=www-data
WorkingDirectory=/home/you/project
Environment="PATH=/home/you/project/venv/bin"
ExecStart=/home/you/project/venv/bin/uwsgi --ini uwsgi.ini

[Install]
WantedBy=multi-user.target

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.