ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pdk
pdk
RE: PerlSvc questions
by Primanti, Joseph T other posts by this author
Feb 28 2002 6:46PM messages near this date
RE: automatically register dll | automatically register dll
David,

You can step through your code if you compile the exe with the -d switch and
replace the original. When the service is started it launches the Perl GUI
Debugger, you can then step through each line of code.

Joe

-----Original Message-----
From: Jan Dubois [mailto:JanD@[...].com]
Sent: Thursday, February 28, 2002 11:27 AM
To: David Hares
Cc: Pdk
Subject: Re: PerlSvc questions


On Thu, 28 Feb 2002 11:45:24 -0500, "David Hares" <dhares@[...].net> 
wrote:

> To those kind enough to reply, it does not appear to be a scope problem.
The code looks something like this:
> 
> $PerlSvc::Name ;
> $PerlSvc::DisplayName ;

You need to assign the values here:

$PerlSvc::Name = "foo";
$PerlSvc::DisplayName = "foo";

> {	# start of code
>    BEGIN {...}
>    END {...}
>    { ... # code to run if started via 'perl foo'
>      &main::main();
>      exit (0);
>    }
> }
> 
> sub PerlSvc::Install {
>     $PerlSvc::Name = "foo";
>     $PerlSvc::DisplayName = "foo";

This will only set Name and DisplayName during "Install" time, but not
when the service is actually running.

> }
> 
> sub PerlSvc::Startup {
>     &main::main();
> }
> 
> sub PerlSvc::Remove {}
> 
> sub PerlSvc::Help {}
> 
> sub main::main() { }
> 
> I know the following is true:
> 
> 	The code at the beginning is executed when the .exe is run with
> 	the -install switch, and then the PerlSvc::Install subroutine is
run.
>       $PerlSvc::Name is set on exit from PerlSvc::Install.
> 
> 	The code at the beginning is executed when the .exe is run with
> 	the -remove switch, and then the PerlSvc::Remove subroutine is run.
>       $PerlSvc::Name is NOT set on entry to PerlSvc::Remove.  I actually
don't
>       expect it to be.
> 
> What I need to know is:
> 
>       Is code at the beginning executed when the service is started via 
> 	the 'start' selection in the services manager, and when is the
PerlSvc::Startup
>       subroutine run. 

If you mean the code in PerlSvc::Startup()?  It is *not* executed when you
'start' the service.  The code at *file scope* is executed, and then
PerlSvc::Startup() is called.

>       $PerlSvc::Name is NOT set on entry to PerlSvc::Startup.  I expect
>       it to be, since the guys who program C++ around here (and disdain
perl) say
>       context is preserved between a service install and start. Is context
preserved?

Don't trust the C++ guys! :)  It isn't even true for C++, so they might be
confused here.  Installation and Service start happen in different
processes.  There is no way that changes to global variables are being
preserved from one process to the other.

>       If it's not preserved, is there any way to pass information from
Install to
> 	Startup?

I don't think so.  You could write information to a file or the registry
during install time and read it back at Startup time.  Could you explain
why you need this?

>       Is there any approved way to check in the code at the beginning it's
being run
>       as a service?  My kludge is to check if PerlSvc::ContinueRun() is
defined.

Testing for PerlSvc::ContinueRun() is fine.

Cheers,
-Jan

_______________________________________________
PDK mailing list
PDK@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
PDK mailing list
PDK@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved