Configuring
a process to run as a service
Once the general
settings are set using the service manager console application, you
are ready to start adding programs to the service manager's execution
list. Each application (EXE program, script, batch file, etc) you configure
will be individually started, stopped, and monitored as specified by the
settings you designate per application.
Step 1: Adding a user program to run as a service.
To add a new program to the service manager list, press the "Add"
button. Please see the following figure:
When you press the Add button, a new dialog will be displayed that will
allow you to specify per process settings for your program.
Step 2: Specify per-process program settings
If you pressed the Add button as specified in step 1, the following dialog
will be displayed:
The following sections will describe the settings available in this dialog:
Command Line:
Use this edit field to specify
the full path command line for your program. Also include any command
line parameters your application may require.
Working Directory:
Use
this edit field to specify the full path of the working directory for
your program.
Enable this application:
This
setting must be enabled for your application to be managed by the service
manager service.
Show user interface:
If
your application has a consol or GUI main window, enable this setting
so the main consol window or main application window gets displayed when
your application is started. Generally you will want this setting to be
disabled.
Use named event for process termination:
If
this setting is enabled, the service manager will create a Windows "named
event" object when it starts your process. This named event can be
used by your program to detect process termination requests by the service
manager. If enabled, the service manager will pass the additional "-ExitEvent
event_name" command line parameter to your program. The service manager
will then set the named event that is specified by the "event_name"
part of the command line parameter when it wants your program to terminate.
Your application can then monitor this named event to determine when it
should terminate processing. This capability is most useful if you are
developing your own application that will be managed by the service manager.
It allows your application to detect exactly when the service manager
wants to terminate your application. Using a named event is generally
more suitable relative to other termination methods such as sending a
GUI application a WM_CLOSE windows message or sending Ctrl+C
to your console based application.
Restart the application if its process terminates:
Enable
this setting if you want the service manager to restart your application
in the event that your application crashes or causes an unhandled exception.
Monitor unhandled application exceptions:
Enable
this setting if you want the service manager to trap unhandled application
exceptions. Enabling this setting will allow the most robust execution
and monitoring of your application. If your application generates an unhandled
exception, the service manager will terminate your application if required
and restart your application if "application restarting" has
been enabled. Application exceptions that are detected are written to
the log file and to the remote log server if enabled.
Periodically restart this application:
If
enabled, the service manager will restart your application at the specified
time interval. This capability is useful for application that may have
resource or memory leaks that occur over time. Restarting applications
that have these issues will allow the host server to reclaim possibly
lost system memory an other resources.
Milliseconds to pause before starting next application:
This
setting is used at service startup. It allows you to specify a delay that
will be applied immediately after your program is started.
Milliseconds to pause before terminating this application:
Allows
you to specify the time the service manager should wait for your program
to terminate. If your program does not terminate in this amount of time,
the service manager will forcefully terminate your application process.
Note: Make sure you set this value to a reasonable value. Terminating
a process forcefully can cause file data to not be flushed.
|