Watchdog Setup

Lifeboat can configure the systemd service to expect WATCHDOG=1 signals from the Web App. When systemd does not get a signal from the Web App within the defined time, systemd will restart the Web App to recover from hang-ups and freezes.

Ensure Advanced Options are enabled and select the Options tab.

The Watchdog Time: field is a value in seconds that should be at least double the time frequency in which the Web App will be sending signals. Leave the field empty or set to 0 to disable the Watchdog app-restarting service.

It is safe to send WATCHDOG=1 signals and ignore them, but expecting signals and not sending them will result in constant Web App restarts!

Lifeboat comes with an easy to install self-contained project to help: WatchdogTimer.xojo_xml_project

Demonstrated in the example project, simply call the Shared WatchdogTimer.Initialize function at the end of the Web App Opening event. This needs to be done as the last step of the App Opening event because it sends a READY=1 message announcing the app is done launching. systemd will wait up to 90 seconds for this signal before performing Watchdog duties.

Sub Opening(args() As String) Handles Opening
  
  // ==== Initialize your app ====
  // Database Connection
  // Other setup
  // Long tasks go here first
  
  
  
  // Watchdog needs to be the very last step of your Web App Opening event
  // because it sends a message to Linux announcing the app is done launching
  WatchdogTimer.Initialize
  
  // The "Application is ready" message prints to Lifeboat's log (from the Web Framework)
  
End Sub

To cleanup properly, call WatchdogTimer.Stopping during the Web App Stopping event. This is also demonstrated in the example project.