Hi all,<br><br>Im trying to get a daemon up and running but have been tripping on every stone along the way, this last one however i cant manage to get by.<br>versions:<br>Python 2.5.2<br>python-daemon-1.5.5<br>Debian Linux 2.6.26-2-686<br>
<br>Some of the problems ive run into: <br><br>import daemon<br>with daemon.DaemonContext():<br> do_main_program()<br><br>doesnt work on my version of Python 2.5.2 so im using <br><br>import daemon<br>import grp<br>import pwd<br>
<br>diablo.uid = pwd.getpwnam('nobody').pw_uid <br>diablo.gid = grp.getgrnam('nogroup').gr_gid <br><br>daemon.__enter__()<br>main()<br>daemon.__exit__()<br><br>Next I had problems with Initd starting the daemon because i forgot to chmod it to 755.<br>
<br>The final problem is with the PID file and getting a correct PID written. Initially there was no file being created, so i thought i needed the --make-pidfile option in start-stop-daemon, but ive since learned that the daemon should create and edit the file, not s-s-d as it inserts the PID of the parent process, which is not the correct PID of the final daemon.<br>
<br>So i added to my daemon: <br><br>import lockfile<br>daemon.DaemonContext(pidfile=lockfile.FileLock('/var/run/mydaemon.pid'),)<br><br><br>which didnt start the daemon at all as i created the pid file as root, and was setting the Daemon to run as nobody,nogroup so it was dieing silently. Im running it as root for now to see if i can get a correct pid in the pid file.<br>
However no PID file is created, and if i create one its not populated with a PID.<br><br>In summary: I cant get a PID file created or pupulated with a PID by python-daemon.<br>Anyone see something that im doing wrong? ive been sitting on this way too long. I looked at the python-daemon source and i cant see where the pid is inserted into the pid file, only where it __enter__'s the lockfile so is this missing?<br>
Thanks!<br>