Running Object Rexx rexx.exe as a NT Service

Running Object Rexx rexx.exe as a NT Service

Post by Michael Lu » Wed, 12 Jan 2005 23:33:46


Does anyone have a good example of running Object Rexx 2.1.3 rexx.exe as a NT Service. Specifically some things come to mind:

1) Setting the new service to only start after RxAPI service, considering a situation where this new service is set to auto-start.
2) Should rexx.exe end, the service is stopped so it could be restarted manually. (In the case of SrvAny, when the program ends, the SrvAny instance does not automatically stop. Instead SrvAny must
run a batch program which runs the other program, and if that program ends it issues a NET STOP on itself.)

I guess those are the main sharp spots that come to mind. Always interested in seeing working examples rather than going it alone. This kind of hack job (using SrvAny) will have to do until I an get a
real NT service program written which is basically a 'rexx.exe NT service' program.

TIA!

--
Michael Lueck
Lueck Data Systems

Remove the upper case letters NOSPAM to contact me directly.
 
 
 

Running Object Rexx rexx.exe as a NT Service

Post by Mark Yudki » Thu, 13 Jan 2005 17:06:57

Only as a real service using RexxStart, sorry. There's a sample service (in
Samples\WinBase\Service) in the MS Platform SDK that can be quickly hacked
into shape, which does the basic SCM interfacing. Take a look at it.

From the readme from that example:

1) The use of the SERVICE.H header file and the accompanying SERVICE.C file
simplifies the process of writing a service. You as a developer simply need
to follow the TODO's outlined in the header file, and implement the
ServiceStart and ServiceStop functions for your service.

There is no need to modify the code in SERVICE.C. Just add SERVICE.C to your
project and link...

As you say, the service should be made dependent on rxapi. Also, note that
2.1.3 with rxapi as a service is an absolute prequisite, as 2.1.2 and
earlier have a range of defects that prevent successful use in a service or
under terminal services.

 
 
 

Running Object Rexx rexx.exe as a NT Service

Post by Michael Lu » Thu, 13 Jan 2005 20:56:11

Thanks for the C pointers, I'll refer to that when we get to building a C version. I think it will probably be something we contribute to OORexx.

Did you happen to somehow notify the running Rexx when the service is being stopped so it could end gracefully? I would like to somehow support that when we develop our version.

--
Michael Lueck
Lueck Data Systems

Remove the upper case letters NOSPAM to contact me directly.
 
 
 

Running Object Rexx rexx.exe as a NT Service

Post by Mark Yudki » Sat, 15 Jan 2005 19:01:05


Please review the sample service I pointed you to - it contains the SCM
interaction for stopping.

The rest is a matter of using some form of internal communication to the
REXX and using RexxWaitForTermination and/or RexxDidRexxTerminate. Services
normally "hang around" waiting for some external request, which they
process. You can use any form of (secure) signalling you like (e.g. event
semaphore - see the Sys*EventSem rxutils routines - this is my approach) or
even just call RexxSetHalt if you like the wooden hammer approach.