Python as RedHat/SysV service

Donn Cave donn at u.washington.edu
Tue Dec 18 16:59:37 EST 2001


Quoth "Stuart D. Gathman" <stuart at bmsi.com>:
| I have a system service written in python.  On RedHat systems, this
| service is conveniently installed and started by placing a script in
| /etc/rc.d/init.d to start,stop,reload, etc the service.  The standard
| methods for checking whether a service is running or sending it a signal
| rely on the process name: e.g. 'inetd'.  In this case, the process name is
| always 'python2'.
|
| Is there a way to change the process name of a running python program?  Or
| is it better to craft a new version of 'pidof' that works for python
| processes?  Has anyone dealt with this before?

As you noticed, that "standard method" isn't a very good one!  What
about other services that run under their own name but fork, like sshd?

Many services, including sshd for example, write their process ID to a
well known file - might be in /etc/budgie.pid, /var/run/budgie.pid, etc.,
depending mostly on the platform.  (Could be defined as _PATH_VARRUN in
paths.h, on fairly modern platforms.)

Then all you have to do is verify that no other process has taken that
ID since then, so you don't kill something else by accident.  Your service
can lock the file, for example, and if it's still locked then it must
be the right file.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list