How to pack a Python daemon using setuptools

How do you package a Python application using setuptools so that when you install it (for example, through setup.py or pip) it puts the script daemon in the appropriate place, starts it and notes that it starts automatically at boot time?

In my case, my code only works with Linux, so I only need to install the daemon in the Linux environment (in particular, Ubuntu).

I found several posts describing how easy it is to create Python daemons, but I cannot find anything describing how you installed them in a production environment so that they can be treated like any other normal daemon or service.

I know that Ubuntu and some other distributions store their daemons in /etc/init.d, and I know how to use setuptools to copy files to specific places on the file system, so it would be safe to copy or symbolize my script to / etc /init.d and then run chkconfig to set the runtime, or is there a safer way to neutralize daemon propagation?

+8
python linux setuptools daemon python-daemon
source share
1 answer

It would be better to solve this by creating the appropriate package for the distribution (in the case of Ubuntu, .deb), since you cannot guarantee the location of startup scripts between distributions. For example, arch linux uses /etc/rc.d/. In addition, copying to such locations will require root access (which, I believe, is not required to install python packages), and can be difficult to reverse when uninstalling.

I would suggest that you create a typical setupttools installation and then package it in deb with a link to / etc / init.d.

+3
source share

All Articles