Oliver Bock wrote:
> I am having problems using the webkit script from my working directory 
> to start AppServer when my machine starts.  The trouble seems to be that 
> webkit loads its old process ID in $PID_FILE, then finds that that 
> particular PID already exists (there are lots of low-numbered processes 
> during startup) and so decides not to run AppServer.

Normally, this should not happen if the script is properly installed as 
a rc start and stop script. When the machine is shut down, webkit should 
be stopped properly and the PID_FILE deleted.

But you're right, it may happen if Webware was not shut down properly 
and there is another process with the same PID running.

So instead of simply testing whether a process exists, we could check 
the process command as well and require it to be something like
"python Launch.py ThreadedAppserver"

But this would still fail if you run several Webware instances. We need 
to check whether the process really belongs to the PID_FILE.

 > Perhaps webkit should use fcntl.flock?

Just so I understand properly: You suggest that the PID_FILE is created 
with a lock (you can also use os.open for that), and then the start 
script checks with "fuser" whether the process in the PID_FILE is the 
same as the one that has PID_FILE locked?  That should work, but it 
would waste a file descriptor, and I'm not sure whether fuser is 
available everywhere.

Maybe the following would be better. It does not need any locking.

PID=`cat $PID_FILE`
if [ tr \\000 \\040 < /proc/$PID/cmdline | grep -q " -i $PID_FILE " ]
then conclude that Webware is still running...

What do you think?

-- Christoph


_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to