TsgcWebSocketServerProperties › WatchDog

WatchDog Property

Automatically restarts the server after an unexpected shutdown or listener failure.

Syntax

property WatchDog: TsgcWSWatchDogServer_Options read FWatchDog write SetWatchDog;

Default Value

Enabled=False

Remarks

Enable WatchDog.Enabled to have the server restart itself after an unexpected stop (for example when the listener socket dies). Interval is the number of seconds to wait before each reconnection attempt; Attempts caps the total number of tries — set it to 0 for unlimited retries. The watch-dog is independent from external process supervisors: it only keeps the in-process listener alive, so it does not recover from full process crashes. Combine with OnStartup/OnShutdown events to track the restart sequence.

Example


oServer := TsgcWebSocketServer.Create(nil);
oServer.WatchDog.Interval := 10;
oServer.WatchDog.Attempts := 0;
oServer.WatchDog.Enabled := true;
oServer.Active := true;

Back to Properties