mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 02:17:27 -04:00
not responding check log time
This commit is contained in:
parent
741ca371cc
commit
ccd53012f5
4 changed files with 42 additions and 17 deletions
|
@ -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)
|
||||
|
|
|
@ -16,6 +16,7 @@ var log_file: FileAccess
|
|||
var pipe: Dictionary
|
||||
var gate: Gate
|
||||
|
||||
var last_log_tick: int
|
||||
var print_logs: bool
|
||||
var logs_sent: bool
|
||||
|
||||
|
@ -31,6 +32,7 @@ func _ready() -> void:
|
|||
func start(_pipe: Dictionary, _gate: Gate) -> void:
|
||||
pipe = _pipe
|
||||
gate = _gate
|
||||
last_log_tick = Time.get_ticks_msec()
|
||||
|
||||
create_log_file()
|
||||
start_reading_pipes()
|
||||
|
@ -81,6 +83,7 @@ func read_stderr() -> void:
|
|||
func store_buffer(buffer: PackedByteArray) -> void:
|
||||
if print_logs: printraw(buffer.get_string_from_utf8())
|
||||
log_file.store_buffer(buffer)
|
||||
last_log_tick = Time.get_ticks_msec()
|
||||
|
||||
|
||||
func cleanup() -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue