Hello everyone,
2010/3/16 <exar...@twistedmatrix.com>: > On 07:27 am, t...@commsecure.com.au wrote: >>On 03/16/2010 06:07 PM, Peter Cai wrote: >>>I think an init.d script could resolve this problem. >>>But I am curious about why "turning off power without shutdown twisted >>>server before" could cause such a problem. >>> >>>Is it a bug or it has some more fundamental reason? >> >>When twistd starts up, it creates a .pid file as a signal that it's >>running. If you try and start it a second time, it notices that the >>.pid >>file exists, and refuses to run a second time. When twistd is shut down >>cleanly, it removes the .pid file so that it can be run again. >> >>Unfortunately, this means that if twistd is shutdown *uncleanly* (by a >>power failure, or SIGKILL, or some other means), the .pid file must be >>removed before twistd will start again. >> >>This isn't really a bug in twistd as such; almost all Unix daemons use >>the same fundamental system. Try running "ls /var/run/*.pid" on a Linux >>system, for example. >> >>It's possible to add refinements to the basic .pid system, to make it >>more resistant to this kind of problem (off the top of my head, >>checking >>that the named PID exists, > > Actually it does this already. But this is a particularly ineffective > check, especially for processes launched at boot time, because of the > very high possibility of collisions. It is possible to retrieve the command line that was used to start a process. This would be a simple way to check for matches. The command line used to start the twistd process could even be stored as well for comparison. >> >>that it's a process of the right kind, >>checking for stale .pid files with exclusive file locks), but all of >>them require more code to implement, reduce portability, and still have >>corner-cases that would require an admin to manually delete the .pid >>file anyway. > > Jean-Paul > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python > Best, -- Alexandre Quessy http://alexandre.quessy.net/ _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python