PackageDescription: WinService


Win Service

Last published: September 16, 2017 by 'klnsrgn'

Defines 5 Classes
Extends 4 Classes


Allows to run an image as a Windows service.

Upon startup, the image needs to start the service handler:

(WinService serviceName: 'MyService')
startAsService: [ " start the service, e.g. open sockets " ]
postStartBlock: [ " evaluated after the socket has started " ]
shutdownBlock: [ " shut down, e.g. close sockets " ].

This method does not return.
The block startAsService should be as brief as possible. After the block has been evaluated, WinService sets the service status to 'running'.
When startup fails, a WinServiceStartupError will be raised. The default action of this signal is to quit the image.
Additional initializations can be performed in the postStartBlock.
The shutdown block will be evaluated when the service is stopped (either by stopping the service or shutting down Windows). After the block has been evaluated, WinService sets the service status to 'stopped'.
Startup and shutdown should not exceed a runtime of 15 seconds, otherwise Windows will report an error.

To install a service:

(WinService serviceName: 'MyService')
installServiceWithParameters: '' " string with command line parameters send to the executable "
prerequisistes: #() " collection of service names "
autoStart: true " true if the service should be automatically started by Windows on startup "
startNow: false " true if the service should be started after installation "

To deinstall a service:

(WinService serviceName: 'MyService')
deinstallService

(which is equivalent to entering "sc delete MyService" in a shell).

The executable is running with system32 / SysWOW64 as current directory,
so you might want to change the current directory on startup, e.g.

CEnvironment commandLine first asFilename directory beCurrentDirectory.


Contact:
c . schuckmann -at- i-views . de
h . kleinsorgen -at- i-views . de

The MIT License

Copyright (c) 2007 Christian Schuckmann and Holger Kleinsorgen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.