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

@ -17,7 +17,7 @@ corner_radius_bottom_left = 16
shadow_color = Color(0, 0, 0, 0.25)
shadow_size = 16
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_o4otx"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_pc71t"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ke42a"]
@ -130,7 +130,7 @@ layout_mode = 2
mouse_default_cursor_shape = 2
theme_override_fonts/font = ExtResource("2_ugt55")
theme_override_font_sizes/font_size = 20
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_o4otx")
theme_override_styles/focus = SubResource("StyleBoxEmpty_pc71t")
theme_override_styles/hover = SubResource("StyleBoxEmpty_ke42a")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_8wfqm")
theme_override_styles/normal = SubResource("StyleBoxEmpty_lr7et")
@ -141,7 +141,7 @@ layout_mode = 2
mouse_default_cursor_shape = 2
theme_override_fonts/font = ExtResource("2_ugt55")
theme_override_font_sizes/font_size = 20
theme_override_styles/hover_pressed = SubResource("StyleBoxEmpty_o4otx")
theme_override_styles/focus = SubResource("StyleBoxEmpty_pc71t")
theme_override_styles/hover = SubResource("StyleBoxEmpty_ke42a")
theme_override_styles/pressed = SubResource("StyleBoxEmpty_8wfqm")
theme_override_styles/normal = SubResource("StyleBoxEmpty_lr7et")

View file

@ -326,10 +326,11 @@ script = ExtResource("10_cqo55")
gate_events = ExtResource("2_q7cvi")
command_events = ExtResource("6_18mgg")
[node name="ProcessChecker" type="Node" parent="."]
[node name="ProcessChecker" type="Node" parent="." node_paths=PackedStringArray("snbx_logger")]
script = ExtResource("11_72cjp")
gate_events = ExtResource("2_q7cvi")
command_events = ExtResource("6_18mgg")
snbx_logger = NodePath("../SandboxLogger")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
custom_minimum_size = Vector2(0, 700)

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)

View file

@ -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: