As described in Introduction to the SystemWeaver Monitor Service, SystemWeaver server applications can be run as a service in Windows. This article describes how to install and configure the Monitor Service.
- Configuring the Service Settings
- Configuring the Service Log
- Installing the Monitor Service
- What's Next?
Prerequisites
- You have successfully tested running all involved server applications directly as executables, i.e., not as a service, using the same versions and setting files. For example, for the SystemWeaver server, you would test by running either the swTestServer or the swDBServer. For the Notification server, you would test by running swTestNotificationServer or swNotificationServer (e.g., see Testing the Notification Server Configuration). If there are any problems with the configurations, they will be more difficult to analyze when the servers are run as a service so it is best to resolve them upfront.
- The server applications' executables and their configuration files are in the locations where they will be run/read. This is because the paths to them will be entered in the service configuration.
- You must have administrator rights to the server machine.
- The Service must have write access to the directories where the log files are generated. SystemWeaver services are normally set to log on as "Local System". Check file locations and access rights to assure the Local System has all the necessary rights.
- An installation of swServerMonitorService. The files can be found in the ServerMonitorService directory (or in the Server directory for pre-R40 versions) in your installation and include the following:
- swServerMonitorService.exe: Manages all SystemWeaver server applications on a server computer. It starts all the server applications automatically and can restart them when necessary.
- swServerMonitorService_install.bat: Installs the SystemWeaver Monitor Service as a service on the server computer.
- swServerMonitorService_uninstall.bat: Uninstalls the SystemWeaver Monitor Service as a service on the server computer.
- Configuration files for swServerMonitorService. They are:
- swServerMonitorService.exe.nlog: Used for configuration of the logging. A sample file is normally supplied in the SystemWeaver installation package in the Configuration files folder. For pre-R41 versions, the file is called swServerMonitorService.props, Nlog.config (for R40) and swServerMonitorService.exe.nlog for Gårda (R41) and later.
- swServerMonitorService.settings: Defines all the server applications and their input files that are run under the service. A sample .settings file is normally supplied in the SystemWeaver installation package in the Configuration files folder. The file format is described below in Format of .settings File.
Configuring the Service Settings
This section will guide you through configuration of the swServerMonitorService.settings file. At this point, all server applications should have already been tested successfully on their own and each server's executable and configuration files (i.e., .ini and .props or .nlog) are in the location where the server application(s) will be run.
- Place the ServerMonitorService folder on the server machine where the SystemWeaver server application is/will be running. The folder should be on a local drive to minimize the dependency on other servers. An example is shown below.
- Open the swServerMonitorService.settings file in a text editor, such as NotePad.
- Configure each server application that will be run by the service using the settings described below.
- Once your settings are correct, click Save to save your changes.
Example Settings
<SystemWeaverMonitor wcfServicePort="9090"> <Servers> <Server restart="true" id="main 1768"> <exe>C:\work\SystemWeaver\bin\swDBServer.exe</exe> <ini>C:\work\SystemWeaver\bin\swServer.ini</ini> <props>C:\work\SystemWeaver\bin\swServer.props</props> </Server> <!--Server id=""> <exe>C:\work\SystemWeaver\bin\swServer.exe</exe> <ini>C:\work\SystemWeaver\bin\swServer2.ini</ini> <props>C:\work\SystemWeaver\bin\swServer2.props</props> </Server--> <Server restart="true" startDelay="10000" id="Rest API 1768"> <exe>C:\Work\Restapi\SystemWeaver.RestApi.exe</exe> </Server> <Server restart="true" startDelay="10000" id="Notification server"> <exe>C:\work\SystemWeaver\bin\swNotificationServer.exe</exe> <ini>C:\work\SystemWeaver\bin\swNotificationServer.ini</ini> <props>C:\work\SystemWeaver\bin\swNotificationServer.props</props> </Server> </Servers> </SystemWeaverMonitor>
In the example shown above, there are 4 server entries, the second of which is commented out with !--. The 3 servers that are set to run will restart automatically. The swNotificationServer and the REST API have a delayed start of 10 seconds to allow the main server executable to start first.
Explanation of Settings
<SystemWeaverMonitor> should contain one <Servers> tag. It has one required attribute called wcfServicePort. Enter a unique port number for the monitor service. If using the Status Tool, the port number entered here should match the port number included in the value (e.g., http://localhost:9090/ServerMonitor) for the "ServerMonitorWCFServiceAddress" key in the Status Tool configuration. Note: wcfServicePort is only applicable in version R40 and later. Do not use with earlier versions.
<Servers> functions to group all <Server> entries.
Note: This tag is only applicable in version R40 and later. Do not use with earlier versions.
A <Server> entry is needed for each server application to be executed on as a service. It has 3 attributes:
- id is required, and is used to identify the application.
Note: This attribute is only applicable in version R40 and later. Do not use with earlier versions. - restart is optional, and controls automatic restart of the server application, in case it has been terminated for some reason. This option makes the installation more robust to unexpected failures. Possible values are 'true' or 'false'
- startDelay is optional, and controls if the server start will be delayed. You can enter a value in number of milliseconds. This is recommended for servers such as swNotificationServer or any other server application which should start just after the SystemWeaver main server executable is started. Example: startDelay="10000" (for 10 seconds).
Executable
The <exe> entry should include the path to and name of the server's executable file.
Configuration File
The <ini> entry should include the path to and name of the server's configuration file, if any. This is not necessary for the Rest API.
Logging Configuration File
The <props> entry should include the path to and name of the server's prop file, if any.
Things to Consider
- Each server should have its unique .ini and .props file (if these files are required by the server) since several settings like the ports of the servers and log files must be unique to each running server application. The same .exe file can however be used for multiple servers (unless different server versions are needed).
- An application started by a service does not have a "home directory". This means that the file paths in the .settings file must be absolute, and not relative.
- All file paths may include space characters, with no need to use quotation marks or apostrophes to enclose the path string.
- The restart attribute should have the value 'false' (or be missing since 'false' is default) until you have started the service fault-free for the first time, since the automatic restart behavior may make other fault tracing troublesome as the service may start repeatedly when errors are detected.
- The files used by a SystemWeaver servers should always be local to the server computer. Using any network file server may affect access performance and reliability.
Configuring the Service Log
To configure logging for the swServerMonitorService, use a text editor to modify the path and file name on the fileName line in the target.
In versions R40, this is done in the "File" target's fileName entry in the Nlog.config file:
For versions R39 and earlier, follow the instructions under Configure the Logging in How to Configure and Start Logging. INFO-level logging is sufficient for the monitor service.
Installing the Monitor Service
Install the Server Monitor service by running the swServerMonitorService_install.bat in a Windows Explorer window.
- To do this, right-click on the file and Run as administrator.
This will open a command prompt window and confirm a successful installation. - Click OK and hit any key to close the window.
Note: Some server machines may require that the service is run by a local administrator. |
To confirm installation, go to the Windows Start menu and type 'Services'.
Select Services. The Services window will display. Scroll down to find the SystemWeaver Monitor Service entry.
Note: For versions R40 and later, the server is called SystemWeaver Server Monitor 2.
By default, Windows sets the Startup Type to Automatic" (i.e., the service starts at system logon). You can change this if desired. Refer to Microsoft for the various Windows Services options.
Tip: If you do not see the entry, you may need to use the Action>Refresh menu option. |
You can right-click on the entry and view Properties to confirm the location of the monitor service installation that is now added as a service.
What's Next?
For instructions on how to start and stop the Monitor Service, see Starting and Stopping the Monitor Service.
Tip: If you are running more than one server application in a service, e.g., a main server, a Rest API, and a notification server, etc., you can consider using the SystemWeaver Monitor Service Status Tool. |