I am using PerlSvc from ActiveState to write an NT Service. To use PerlSvc, the code is wrapped in a package with the main loop inside a while loop (see below).
while (ContinueRun()) {
# your loop code here
# sleep
}
That is not a problem. The problem arises in that while the loop is sleeping, it can not be interrupted (i.e. In UNIX I can trap a signal and exit, awake, etc). Under NT (using PerlSvc), I've not found a way to do this. When a user goes to Stop the NT Service from the Services Menu, it hangs until the Stop times out or the loop wakes up and checks ContinueRun(). In the past I've had a $Asleep variable and check it when coming into the while loop. If it is true, I sleep 20 more seconds; if it is false, I run the real code and then set it to true. I do this until I've slept X amount (defined by the user).
The problem I am now having is that I want the NT Service to be a SOAP server (using SOAP::Lite). If you recall, to start a SOAP::Lite daemon listening you run
$daemon->handle(). This gives control to the SOAP::Lite module. Oops! How can I check the ContinueRun() function that let's me listen for NT telling me to stop? Is there a way (aside from modifying SOAP::Lite) to check ConitnueRun()? I've considered using POE and making the code ACT threaded, but that seems like a big undertaking just to check a function.
Your thoughts are GREATLY appreciated,
Casey
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.