On Sep 21, 9:47 pm, de...@web.de (Diez B. Roggisch) wrote: > vineet daniel <vineetdan...@gmail.com> writes: > > 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. > > The above code looks errornous - you don't check for the return-value of > PID & take appropriate action. Like > > There is a daemonization recipe on active-state, which works nicely for > me. > > http://code.activestate.com/recipes/278731-creating-a-daemon-the-pyth... > > Diez
Hi Diez Thanks for pointing that out. Ever tried giving input to such python daemons from a dynamic source like Apache logs which get generated in real time. I want apache to directly write to this python daemon which in turn will process the logs the way I want. Any help will help me immensely. -- http://mail.python.org/mailman/listinfo/python-list