If you are a TCL programmer, you may get the following advantages by porting your server application to Winserv:
- Using tclkit or freewrap for easy deployment becomes possible. With tclsvc it used to be a problem, and you had to choose between the ease of deployment and the possibility to run as NT service.
- Winserv will help you to implement a Tk dialog to manage your service. With tclsvc you had to use some other utilities or libraries to control your service. Now you can use Winserv both as a service starter and a service-controlling backend.
- Winserv will let you to add support for paused service state and for user-defined signals to your server application. There was no way to get this working with tclsvc, firedaemon, srvany and other similar tools.
Porting
tclsvc-based applications to winserv is easy. You should install a winserv support package at a place where your interpreter can find it, and then add two lines of code at the beginning of your script:
Note that it won't prevent your script from being run by [tclsvc]: winserv support package checks
tcl_service global varible and doesn't try to connect winserv if the variable already exists.
When running under winserv,
winserv::startup command sets the
tcl_service and
tcl_service_winserv global variables to 1. It imports
eventlog command into the global namespace. This command is a
mostly-compatible (though less powerful) replacement for the tclsvc's eventlog. It doesn't open the eventlog directly; instead, it uses the active IPC method to
pass messages to winserv.
A lot of
winserv-specific facilities become available after winserv::startup.
This command lets the application accept certain SCM control code groups.If the dash precedes the group name, it means that this group is not accepted any more.
Use it to accept only the STOP code, as winserv does by default.
This command defines a script to handle particular SCM control code (STOP, PAUSE, CONTINUE, PARAMCHANGE, NETBINDADD, NETBINDREMOVE, NETBINDDISABLE, NETBINDENABLE, as well as
user-defined codes CODE128..CODE255).
For PAUSE and CONTINUE control codes the script can break or throw an error to indicate that the service status wasn't really changed (so it must leave running or paused, respectively).
Use empty script argument to remove the handler.