TsgcWebSocketServer_HTTPAPI › 属性 › WatchDog
在意外关闭或监听器故障后自动重启服务器。
property WatchDog: TsgcWSWatchDogServer_Options read FWatchDog write SetWatchDog;
Enabled=False
启用 WatchDog.Enabled 可在意外停止(例如 http.sys 请求队列停止)后让服务器自动重启。Interval 是每次重连尝试之间等待的秒数;Attempts 限制总尝试次数,设置为 0 表示无限重试。看门狗独立于外部进程监督程序:它仅保持进程内监听器存活,因此无法从完整进程崩溃中恢复。结合 OnStartup/OnShutdown 事件以跟踪重启序列。
oServer := TsgcWebSocketServer_HTTPAPI.Create(nil);
oServer.WatchDog.Interval := 10;
oServer.WatchDog.Attempts := 0;
oServer.WatchDog.Enabled := true;
oServer.Active := true;