You can't KILL a script, start a new instance of that script and pass open TCP socket connections from the deceased script to the new process easily.

Agreed.

You say reload the script completely but you don't seem to want that. You want to reinitialize some stuff but keep some stuff in the running code.

Depending on the code, and based on the OP's question, it may be sufficient to reload any modules that have changed on disk, and perhaps also any configuration files.

Tachyon's earlier post gives a good skeleton for this; what's missing is something to reload any modules that have changed. I think that a hacked copy of Apache::StatINC would do the job -- take the code from handler sub, without the first four lines which are Apache-specific.

However, note that reloading the code this way is a bit unusual, and some of your code may need to be readjusted a bit to avoid some "gotchas," such as re-initializing package variables, leaving dangling references to old data, or other unexpected surprises.


In reply to Re: Re: Re: Restarting a script without dropping clients by simonm
in thread Restarting a script without dropping clients by Ahbeyra

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.