How to create a web interface for a daemon written in Python?

John La Rooy larooy at xtar.co.nz
Tue May 14 06:23:26 EDT 2002


signals are an easy way to talk to daemons
use:
kill -HUP `cat mypid`
kill -USR1 `cat mypid`
kill -USR2 `cat mypid`

of course the kill has to be run by the same user as the script

John

#!/usr/local/bin/python
import signal,time, os

def hup_handler(signum, frame):
    print "RESET"

def usr1_handler(signum, frame):
    print "STOP"
    signal.pause()

def usr2_handler(signum, frame):
    print "START"

signal.signal(signal.SIGHUP, hup_handler)
signal.signal(signal.SIGUSR1, usr1_handler)
signal.signal(signal.SIGUSR2, usr2_handler)
open("mypid","w").write(str(os.getpid()))

while 1:
    print "."
    time.sleep(1)


On Mon, 13 May 2002 17:05:04 +0200
Markus <listuser at nicetomeetyou.to> wrote:

> Hi all,
> 
> we're using a Python script as a watchdog for another process.
> The watchdog is running in console mode, so it is necessary to access the 
> terminal it is running on to operate the program.
> 
> I'm thinking about a remote control feature via a web interface, running the 
> script in the background. The interface simply has to provide access to the 
> 3 basic functions of the watchdog script, i.e. "start", "stop" and "reset", 
> all of which don't need any parameters.
> 
> Can anybody give me a hint about the best way to do this? (Or even better, a 
> hint to a working implementation of something similar ...)
> 
> TIA,
> Markus



More information about the Python-list mailing list