"be consistent" | |
PerlMonks |
Re: Process Reliablityby atl (Pilgrim) |
on Jul 20, 2000 at 15:58 UTC ( [id://23353]=note: print w/replies, xml ) | Need Help?? |
Nice, elegant suggestions, and I would recommend using
the pid file approach. There is a trick how you can
make this file disappear even if the process crashes
(some inode trickery, but I cannot give an example
right now). If you need a quick hack, I can offer you two low level solutions (sort of). Assuming you are using some sort of unix, you might want to try this: 1. Use a wrapper script to start your program. It can restart it whenever the program crashed: Advantage: the auto restart releaves you of checking all the time. Beware, though, that this might mean trouble if your program does ugly things when restarted after a crash and might put considerable load on your machine in a continous start-crash-restart cycle if you omit a proper sleep time. 2. You might grep through the process list to see if you program is running. This works if it has a sufficiently long and distinct name. Try on a shell: or depending on which unix flavour you use. This returns the number of instances of your program running (i.e. usually 0 or 1). YOu can use that from a perl script, too, putting the expression into backticks (``). Hope that's a bit useful. Kind of old techniques, but it still works (most of the time) ;-) Andreas
In Section
Seekers of Perl Wisdom
|
|