0

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 and sudo service nginx restart.

Is there any way to allow people to install my program like this? Perhaps making an install.py file that does it for them? I want people to be able to clone my Github repository for this project and walk through a few steps to install the program.

BigBerger
  • 1,765
  • 4
  • 23
  • 43
  • possible duplicate http://stackoverflow.com/questions/4705564/python-script-as-linux-service-daemon – Achayan Sep 09 '15 at 00:03

1 Answers1

0

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
class YourDaemon(Daemon):
        def run(self):
            # Your code here

An alternative is to use the supervisord process control system.

Erik
  • 135
  • 1
  • 4
  • 12