Overview

In some situations, a process running on your system might suddenly being terminated and you may not have much clues about the cause. The process itself doesn't have the opportunity to output any error in the terminal or its log file.

This can happen if the process crashed, but also if it is being killed by another process running on the system. For example, certain anti-virus softwares sometimes take the initiative to kill a process which is believed to have potential threats. When your program is being killed, you would certainly like to know which process is responsible for that. Usually you would use a debugging tool like gFlags to trace which process sent the kill signal. However, you might not have it installed on your machine, or you might not want to use such tool in production.

Starting from version 3.5.42, the Wrapper can be configured to log an output in the Windows Event Log whenever it terminates unexpectedly. It is also possible to configure the same behaviour for its monitored Java process.

This feature can be enabled or disabled by just changing the values of the properties below.

For the above properties to take effect, you will need to run the Wrapper with the '--setup'. Adminitrator credentials will be asked if not already granted.

Example 1 (Run the setup with a command line):
> .\wrapper.exe --setup ../conf/wrapper.conf
wrapperm | Registering to the Event Log system...
wrapperm | Enabling silent exit monitoring for the Wrapper process...
wrapperm | Diabling silent exit monitoring for the Java process...
wrapperm | Setup done successfully.

A template batch file called 'SetupApp.bat.in' is also provided in the src/bin folder where the Wrapper is installed. Please refer to the following page for explanation on customizing the template batch files. Once your batch file is ready, you will be able to run the setup by simply executing it.

Example 2 (Run the setup with the batch file):
> .\SetupTestWrapper.bat
wrapperm | Registering to the Event Log system...
...

Once the monitoring is enabled, each exit of the Wrapper will generate an output in the Windows Event Log. If you open the Event Viewer (under 'Control Panel > Administrative Tools'), you will see the following output in the 'Application' section:

As you can see, this output shows which process killed the Wrapper (in our example Taskmgr.exe) and also indicates the termination code of the Wrapper process.

To disable exit monitoring, you can set wrapper.monitor_exit (or wrapper.java.monitor_exit) to DISABLED and re-run the Wrapper with the '--setup' command. Alternatively, you may leave the property as is, and run the Wrapper with the '--teardown' command or run the teardown batch file.

NOTE

With this monitoring feature is enabled, an output will be logged to the Event Log whenever the Wrapper or the Java process exits, regardless its exit code. In normal situations you might want disable this feature to avoid cluttering the Event Log.

WARNING

The monitoring feature is enabled per binary name, and not per process. This means that if there are other instances of the Wrapper running on the machine (or other Java processes, when monitoring Java) with the same binary name, the Event Log will also detect and respond to those process terminations.

If you want only a specific instance of the Wrapper to be monitored, you may rename wrapper.exe and give it a name which is unique on the machine.

If another instance of the Wrapper with the same binary name is started while the monitoring is enabled but wrapper.monitor_exit is not set to ENABLED in its configuration file, the Wrapper will log the following warning:

wrapper  | Exit Monitoring is enabled for the Wrapper process.
wrapper  |  Whenever the process exits, an output indicating the reason/origin of the
wrapper  |  termination will be logged to the Event Log. In normal situations you might
wrapper  |  want disable this feature to avoid cluttering the Event Log.
wrapper  |  If this feature should be enabled set the wrapper.monitor_exit property to 'ENABLED',
wrapper  |  otherwise set it to 'DISABLED' and run the Wrapper with the '--setup' command.

Monitor exit of the Wrapper process

wrapper.monitor_exit

Compatibility :3.5.42
Editions :Professional EditionStandard EditionCommunity Edition (Not Supported)
Platforms :WindowsMac OSX (Not Supported)Linux (Not Supported)IBM AIX (Not Supported)FreeBSD (Not Supported)HP-UX (Not Supported)Solaris (Not Supported)IBM z/Linux (Not Supported)

Specifies whether the Event Log should log an output when the Wrapper process exits silently.

Possible values are:

  • ENABLED :

    to turn on the feature.

  • DISABLED :

    to turn off the feature.

  • UNCHANGED :

    to leave the feature as it is.

The default value is UNCHANGED.

Example (monitor exit of the Wrapper process):
wrapper.monitor_exit=ENABLED

Monitor exit of the Java process

wrapper.java.monitor_exit

Compatibility :3.5.42
Editions :Professional EditionStandard EditionCommunity Edition (Not Supported)
Platforms :WindowsMac OSX (Not Supported)Linux (Not Supported)IBM AIX (Not Supported)FreeBSD (Not Supported)HP-UX (Not Supported)Solaris (Not Supported)IBM z/Linux (Not Supported)

Specifies whether the Event Log should log an output when the Java process exits silently.

Possible values are:

  • ENABLED :

    to turn on the feature.

  • DISABLED :

    to turn off the feature.

  • UNCHANGED :

    to leave the feature as it is.

The default value is UNCHANGED.

Example (monitor exit of the Java process):
wrapper.java.monitor_exit=ENABLED

NOTE

When the Wrapper starts, it requests the Java version by launching Java with the '--version' argument. If exit monitoring is enabled for the Java process, this will result in one additional output in the Event Log.