creating python daemon ?

vineet daniel vineetdaniel at gmail.com
Tue Sep 21 08:49:38 EDT 2010


Hi

I have succesfully created daemon with python script and as next step
I am trying to give input to that python script daemon from Apache
Logs....here I have got stuck and I have even checked IRC python
channel for solution. Apache is able to call the file but fails to
execute it properly and I get this error continuosly :

piped log program '/var/www/html/test.py' failed unexpectedly

How do I rectify the above error and make adjustment to the code so
that it takes input from apache.

code that I am using is as follows :

#! /usr/bin/env python
import sys,os
pid = os.fork()
os.chdir("/var/www/html/")
os.setsid()
os.umask(0)
#this line will read apache log in real time as redirected from the
CustomLog directive of Apache.
log = sys.stdin.readlines()
f = open('/var/www/logmongo.txt','a') # append log to this text file
f.write(log)

I'd appreciate if anybody could share the code that they used for
daemon or used with Apache CustomLog directive.



More information about the Python-list mailing list