I do have the following situation.
A perl script that is running as a monitor for an application on Linux, I named it applMon. It does checks thing like are all processes running. The job here is to do an automatic restart if one of these processes is missing. This is all working so far.
But sometimes the shutdown respectively the startup command, which is run by e.g. qx(shutdown) or qx(startup) from the monitoring script, hangs. For that reason I wrote another script, let’s call it restartCompletenessCheck.
Now I’d like to start the restartCompletenessCheck script before I do run the shutdown on the corresponding application. In the restartCompletenessCheck script I do sleep for 60 seconds to give the application shutdown some time to finish via sleep. Now how can I achieve to run the restartCompletenessCheck script independently from the monitoring script dynamically? I was thinking about implementing fork in the applMon script. But fork runs another copy of the originating script which would then cause problems like start of the application twice and so on.
Do any of wise and astute monks have a concept on how to solve this issue? Thank you for your precious time to spend on such small problems.
p_boarderscript applMon
check();
if check eq negative
Run restartCompletenessCheck();
qx(shutdown);
sleep 60;
checkThatEverythingIsStopped();
if (everThingStopped)
startApplication();
else
kill all application processes still running
checkThatEverythingIsStopped();
startApplication();
else
doWriteLogMessage(everyThinIsOk);
script restartCompletenessCheck
sleep 60 sec;
if (processes from shutdown are still running)
kill(them);
done
In reply to Run Perl script from another perl script independently by p_boarder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |