not responding check log time

This commit is contained in:
Nordup 2024-11-03 03:12:35 +04:00
parent 741ca371cc
commit ccd53012f5
4 changed files with 42 additions and 17 deletions

View file

@ -2,33 +2,54 @@ extends Node
@export var gate_events: GateEvents
@export var command_events: CommandEvents
@export var snbx_logger: SandboxLogger
# Timeout interval for child process responsiveness
const BOOTUP_INTERVAL = 30
const HEARTBEAT_INTERVAL = 5
const WAIT_INTERVAL = 20
# Timeout intervals for child process responsiveness
const BOOTUP_CHECK_SEC = 1
const BOOTUP_INTERVAL_MSEC = 5000
const HEARTBEAT_INTERVAL_SEC = 5
const WAIT_INTERVAL_SEC = 15
var timer: Timer
var bootup_timer: Timer
var heartbeat_timer: Timer
func _ready() -> void:
timer = Timer.new()
add_child(timer)
timer.timeout.connect(on_timeout)
bootup_timer = Timer.new()
heartbeat_timer = Timer.new()
add_child(bootup_timer)
add_child(heartbeat_timer)
gate_events.gate_entered.connect(start_bootup_timer)
bootup_timer.timeout.connect(bootup_check)
heartbeat_timer.timeout.connect(on_timeout)
gate_events.gate_entered.connect(start_bootup_check)
gate_events.first_frame.connect(start_heartbeat_timer)
command_events.heartbeat.connect(restart_heartbeat_timer)
func start_bootup_timer() -> void:
timer.start(BOOTUP_INTERVAL)
func start_bootup_check() -> void:
bootup_timer.start(BOOTUP_CHECK_SEC)
func bootup_check() -> void:
var interval = Time.get_ticks_msec() - snbx_logger.last_log_tick
if interval < BOOTUP_INTERVAL_MSEC: return
bootup_timer.stop()
on_timeout()
func start_heartbeat_timer() -> void:
if not bootup_timer.is_stopped(): bootup_timer.stop()
heartbeat_timer.start(HEARTBEAT_INTERVAL_SEC)
func restart_heartbeat_timer() -> void:
timer.start(HEARTBEAT_INTERVAL)
heartbeat_timer.start(HEARTBEAT_INTERVAL_SEC)
func on_timeout() -> void:
Debug.logerr("Gate is not responding")
gate_events.not_responding_emit()
timer.start(WAIT_INTERVAL)
heartbeat_timer.start(WAIT_INTERVAL_SEC)