Sw4me: Winserv/Tcl (Microsoft Word ready version)

If you are a TCL programmer, you may get the following advantages by porting your server application to Winserv:

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.