Macphisto has asked for the wisdom of the Perl Monks concerning the following question:
I install the daemon with this:use Win32::Daemon; open ( OUT, "C:\\Out.txt" ) || die ( "Unable to open file: $!" ); Win32::Daemon::StartService(); while ( SERVICE_STOPPED != ( $State = Win32::Daemon::State() ) ) { if ( SERVICE_START_PENDING == $State ) { print OUT "Starting Service\n"; Win32::Daemon::State( SERVICE_RUNNING ); } elsif ( SERVICE_PAUSE_PENDING == $State ) { print OUT "Pausing Service\n"; Win32::Daemon::State( SERVICE_PAUSED ); } elsif ( SERVICE_CONTINUE_PENDING == $State ) { print OUT "Resuming Service\n"; Win32::Daemon::State( SERVICE_RUNNING ); } elsif ( SERVICE_STOP_PENDING == $State ) { print OUT "Service Stopping"; Win32::Daemon::State( SERVICE_STOPPED ); } elsif ( SERVICE_RUNNING == $State ) { print OUT "Service Running"; } sleep(5); } Win32::Daemon::StopService();
And it installs happily. But when I open up Services, and choose "Start" I get: The service did not respond to the start or control request in a timely fashion#!/usr/bin/perl -w use Win32::Daemon; my %ServiceConfig = ( name => "TestService", display => "Testing a Perl Created Service", path => $^X, user => '', passwd => '', parameters => 'c:\Perl\scripts\TestService.pl', ); if ( Win32::Daemon::CreateService ( \%ServiceConfig ) ) { print "The '$ServiceConfig{display}' service"; print "was successfully installed.\n"; } else { print "Failed to add '$ServiceConfig{dislay}' service\n"; print "Error:"; print Win32::FormatMessage( Win32::Daemon::GetLastError() ), "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re: Win32::Daemon
by tye (Sage) on Jun 18, 2001 at 18:38 UTC | |
by donaldm314 (Pilgrim) on Jun 19, 2001 at 02:51 UTC | |
by tye (Sage) on Jun 19, 2001 at 09:43 UTC | |
by Macphisto (Hermit) on Jun 18, 2001 at 18:57 UTC | |
Re: Win32::Daemon
by donaldm314 (Pilgrim) on Jun 19, 2001 at 01:25 UTC |