security component serves for increasing the stability and security of running applications (PROMOTIC applications in particular). PROMOTIC applications are very often created in order to run 24 hours a day, 365 days a year (non-stop). These applications are often located in remote sites that are only rarely visited. Therefore it is requested that the system recoveres automatically after possible failure. In such case the PmRtManager
can complete this by restarting the application or the whole computer if necessary.
There is a special kind of software used for such purposes, called WatchDog
. Usually this is a small program that is used for watching the functionality of other programs (in our case the PROMOTIC applications). If the application is stoped unexpectedly (crashes or someone stopps it, etc.), then the WatchDog
program restarts it (terminates it and relaunches) or restarts the whole computer. The WatchDog
program is also responsible for relaunching the application after the computer reboots. In the PROMOTIC system, the PmRtManager.exe program works as WatchDog
(see PmRtManager - manager of running apps
When launched, the PmRtManager
reads its configuration from the PmRtManager.ini
file. Then launches the required (watched) programs, assigns the desired initial values of counters and then decrements these counters periodically. If some counter reaches 0, then the PmRtManager
supposes that the application crashed and forces it to restart (or restarts the computer). In order to prevent the PmRtManager
from periodically restarting the PROMOTIC application, this application must call the Pm.WDogRefresh
periodically. By calling this method, the counters are reset to desired initial values. If the application calls such method regulary, then the counter never reaches zero (and does not restart the application).
The manager of runnig applications PmRtManager
can run as service OS Windows
or as a normal application. In both cases the functionality is similar. For the program parameters see PmRtManager as service
Example of PmRtManager.ini file in \GCfg (for 2 programms):
' Period of counter decrement (in milliseconds)
' Password for enabling the PmRtManager.exe termination
' Sets port where the PmRtManager functionality can be monitored via HTTP. If not set, then the port 81 is used.
' Name of the 1st watched program
' Parameter for the 1st watched program
' If the PmRtManager closes the 1st program, then it even closes a program with the number assigned in this item
' Pause between the PmRtManager.exe and the 1st program starting. The value is in "Period" units.
' Value that is written into the counter on starting the program. If this value is 0, then the program is not watched. The counter is decremented (decreased by 1) at the period "Period".
' Period between terminating and restarting the program (or restarting the OS Windows). The value is in "Period" units.
' If the 1st program does not set the counter at least once after starting and the counter reaches 0, then: if RestartWindows=1, then the Windows restarts immediately, if RestartWindows=0, then it tries to close the 1st program and then to restart it.
' The number of attempts the PmRtManager tries to close and restart the program before restarting the whole computer. If RestartProgram=-1, then the number of attempts is not limited.
- If we don't want to watch a program but only to start it, then enter the item IniCounter=0.
- To prevent Windows restarts, enter the items RestartWindows=0 and RestartProgram=-1.
- We want to watch the Program1. We don't want to watch the Program2 but we want to stop and restart it dependently on the Program1.
Solution: State in the PmRtManager.ini file in the section [Program1] the key RestartOtherProgram=2 and in the section [Program2] the key IniCounter=0.
- If the item LogEnable=1 is enabled, then PmRtManager events are written into the PmRtManager.log file that is automatically created in the folder where the PmRtManager.exe file is located.
How to WatchDog your program
Each program has its own independent counter and may exist in different phase (different state of watching). The current phase of a program can be seen in the main window of the PmRtManager.exe program or via HTTP monitoring.
Description of individual phases follows:
Ini - Initialization of variables. The StartDelay phase follows.
StartDelay - If non-zero StartDelay is set, then the PmRtManager waits for this period of time. After the defined time passes (or immediatelly, if StartDelay is not set or is set to 0), the PmRtManager launches the specified program and sets the corresponding counter to the value defined in IniCounter. If IniCounter is not equal to zero, then the RtManager goes to Control phase. If IniCounter is not set or equals to zero (i.e. the program is not to be watched), then it goes to the NoControl phase
Control - PmRtManager repeatedly decreases the value of the counter with the period defined in Period parameter (in PmRtManager.ini). Once the counter reaches 0 (i.e. the watched program was unable to reset the counter), it executes an action based on defined parameters RestartWindows and RestartProgram (see the PmRtManager.ini example below). Based on this, it goes to the RequestStop or RestartWin phase.
RequestStop - PmRtManager stopps the program. Then goes to the StopDelay phase.
StopDelay - PmRtManager waits after the program is stopped (before it is re-launched) for the StopDelay period of time. After that time it goes to the Ini phase.
NoProgram - The Program was not defined in PmRtManager.ini. PmRtManager stopped attendance for this program.
NoControl - The Program has been launched but is not watched. The IniCounter item was set to 0. PmRtManager can stop and re-launch this program based on another program defined in RestartOtherProgram item.
RestartWin - the OS Windows system will be restarted.
The manager of running applications PmRtManager
) completely replaces the original PmWDog.exe
program that is no longer included into PROMOTIC installation. The essential configuration items inside the configuration file are identical for both old and new WatchDog
, making the transition to new WatchDog
very easy. Basically, it is sufficient just to rename the old PmWDog.ini
configuration file to PmRtManager.ini
and copy it to the same folder as the PmRtManager.exe
The batch file itself, e.g.: autostart.bat
must be saved into the folder containing the PmRtManager.exe
file and its Windows
shortcut for Start Up. See RunLater program