Hi fellow monks, I've got a little problem when trying to use Win32::Daemon module...

My goal : I want to create a "daemon" for a win32 system. The only way I found (not a windows expert though...) is to make my script a service, thanks to Win32::Daemon.

So I created the following test script (from the Win32::Daemon first example) :

use Win32::Daemon; # Tell the OS to start processing the service... Win32::Daemon::StartService(); print "Waiting...\n"; # Wait until the service manager is ready for us to continue... print "SERVICE_NOT_READY " . SERVICE_NOT_READY . "\n"; print "SERVICE_STOPPED " . SERVICE_STOPPED . "\n"; print "SERVICE_RUNNING " . SERVICE_RUNNING . "\n"; print "SERVICE_PAUSED " . SERVICE_PAUSED . "\n"; print "SERVICE_START_PENDING " . SERVICE_START_PENDING . "\n"; print "SERVICE_STOP_PENDING " . SERVICE_STOP_PENDING . "\n"; print "SERVICE_CONTINUE_PENDING " . SERVICE_CONTINUE_PENDING . "\n"; print "SERVICE_PAUSE_PENDING " . SERVICE_PAUSE_PENDING . "\n"; while( SERVICE_START_PENDING != Win32::Daemon::State() ) { sleep( 1 ); print Win32::Daemon::State() . "\n"; } print "Running...\n"; # Now let the service manager know that we are running... Win32::Daemon::State( SERVICE_RUNNING ); # Okay, go ahead and process stuff... unlink( glob( "c:\\temp\\*.tmp" ) ); # Tell the OS that the service is terminating... Win32::Daemon::StopService();
and I have this :
Waiting... SERVICE_NOT_READY 0 SERVICE_STOPPED 1 SERVICE_RUNNING 4 SERVICE_PAUSED 7 SERVICE_START_PENDING 2 SERVICE_STOP_PENDING 3 SERVICE_CONTINUE_PENDING 5 SERVICE_PAUSE_PENDING 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 Terminating on signal SIGINT(2)

So it never reaches the SERVICE_RUNNING state : it passes from SERVICE_NOT_READY to SERVICE_STOPPED...
Any idea on the problem ? I run Windows XP SP1, with ActivePerl 5.8.4.

Many thanks


--
zejames

20040915 Edit by castaway: Changed title from 'Problems with Win32::Daemon'


In reply to Win32::Daemon service doesn't reach RUNNING state by zejames

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.