Dear Monks of wisdom

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_boarder

Pseudo Code :

script 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.