Skip to content Skip to sidebar Skip to footer

Installing My Python Program As A Service In Ubuntu

I am trying to figure out how to release a Python program I wrote and have it be able to be run as a service in Ubuntu. Much like Nginx, where you can call sudo service nginx stop

Solution 1:

You could have it run as a daemon. Doing this would allow you to run the stop and restart commands you mentioned.

For example:

python program.py stop

python program.py restart

Install the python-daemon package in Ubuntu.

sudo apt-get install python-daemon

from daemon import Daemon
classYourDaemon(Daemon):
        defrun(self):
            # Your code here

An alternative is to use the supervisord process control system.

Post a Comment for "Installing My Python Program As A Service In Ubuntu"