mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-22 23:17:26 -04:00
check if sandbox is running on bootup
This commit is contained in:
parent
d1aa1e6536
commit
e31fa51046
4 changed files with 32 additions and 9 deletions
|
@ -165,11 +165,11 @@ script = ExtResource("10_cqo55")
|
||||||
gate_events = ExtResource("2_q7cvi")
|
gate_events = ExtResource("2_q7cvi")
|
||||||
command_events = ExtResource("6_18mgg")
|
command_events = ExtResource("6_18mgg")
|
||||||
|
|
||||||
[node name="ProcessChecker" type="Node" parent="." node_paths=PackedStringArray("snbx_logger")]
|
[node name="ProcessChecker" type="Node" parent="." node_paths=PackedStringArray("snbx_manager")]
|
||||||
script = ExtResource("11_72cjp")
|
script = ExtResource("11_72cjp")
|
||||||
gate_events = ExtResource("2_q7cvi")
|
gate_events = ExtResource("2_q7cvi")
|
||||||
command_events = ExtResource("6_18mgg")
|
command_events = ExtResource("6_18mgg")
|
||||||
snbx_logger = NodePath("../SandboxLogger")
|
snbx_manager = NodePath("../SandboxManager")
|
||||||
|
|
||||||
[node name="WorldCanvas" type="Control" parent="."]
|
[node name="WorldCanvas" type="Control" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
|
@ -2,11 +2,10 @@ extends Node
|
||||||
|
|
||||||
@export var gate_events: GateEvents
|
@export var gate_events: GateEvents
|
||||||
@export var command_events: CommandEvents
|
@export var command_events: CommandEvents
|
||||||
@export var snbx_logger: SandboxLogger
|
@export var snbx_manager: SandboxManager
|
||||||
|
|
||||||
# Timeout intervals for child process responsiveness
|
# Timeout intervals for child process responsiveness
|
||||||
const BOOTUP_CHECK_SEC = 1
|
const BOOTUP_CHECK_SEC = 1
|
||||||
const BOOTUP_INTERVAL_MSEC = 5000
|
|
||||||
const HEARTBEAT_INTERVAL_SEC = 5
|
const HEARTBEAT_INTERVAL_SEC = 5
|
||||||
const WAIT_INTERVAL_SEC = 15
|
const WAIT_INTERVAL_SEC = 15
|
||||||
|
|
||||||
|
@ -33,8 +32,7 @@ func start_bootup_check() -> void:
|
||||||
|
|
||||||
|
|
||||||
func bootup_check() -> void:
|
func bootup_check() -> void:
|
||||||
var interval = Time.get_ticks_msec() - snbx_logger.last_log_tick
|
if snbx_manager.is_sandbox_running(): return
|
||||||
if interval < BOOTUP_INTERVAL_MSEC: return
|
|
||||||
|
|
||||||
bootup_timer.stop()
|
bootup_timer.stop()
|
||||||
on_timeout()
|
on_timeout()
|
||||||
|
|
|
@ -16,7 +16,6 @@ var log_file: FileAccess
|
||||||
var pipe: Dictionary
|
var pipe: Dictionary
|
||||||
var gate: Gate
|
var gate: Gate
|
||||||
|
|
||||||
var last_log_tick: int
|
|
||||||
var print_logs: bool
|
var print_logs: bool
|
||||||
var logs_sent: bool
|
var logs_sent: bool
|
||||||
|
|
||||||
|
@ -32,7 +31,6 @@ func _ready() -> void:
|
||||||
func start(_pipe: Dictionary, _gate: Gate) -> void:
|
func start(_pipe: Dictionary, _gate: Gate) -> void:
|
||||||
pipe = _pipe
|
pipe = _pipe
|
||||||
gate = _gate
|
gate = _gate
|
||||||
last_log_tick = Time.get_ticks_msec()
|
|
||||||
|
|
||||||
create_log_file()
|
create_log_file()
|
||||||
start_reading_pipes()
|
start_reading_pipes()
|
||||||
|
@ -83,7 +81,6 @@ func read_stderr() -> void:
|
||||||
func store_buffer(buffer: PackedByteArray) -> void:
|
func store_buffer(buffer: PackedByteArray) -> void:
|
||||||
if print_logs: printraw(buffer.get_string_from_utf8())
|
if print_logs: printraw(buffer.get_string_from_utf8())
|
||||||
log_file.store_buffer(buffer)
|
log_file.store_buffer(buffer)
|
||||||
last_log_tick = Time.get_ticks_msec()
|
|
||||||
|
|
||||||
|
|
||||||
func cleanup() -> void:
|
func cleanup() -> void:
|
||||||
|
|
|
@ -128,5 +128,33 @@ func kill_sandbox_macos() -> void:
|
||||||
Debug.logclr("Process killed " + str(snbx_pid), Color.DIM_GRAY)
|
Debug.logclr("Process killed " + str(snbx_pid), Color.DIM_GRAY)
|
||||||
|
|
||||||
|
|
||||||
|
func is_sandbox_running() -> bool:
|
||||||
|
if snbx_pid == 0: return false
|
||||||
|
|
||||||
|
match Platform.get_platform():
|
||||||
|
Platform.WINDOWS:
|
||||||
|
var output = []
|
||||||
|
OS.execute("cmd.exe", ["/c", "tasklist", "|", "findstr", snbx_pid], output)
|
||||||
|
Debug.logclr("tasklist: " + str(output), Color.DIM_GRAY)
|
||||||
|
return not output[0].is_empty()
|
||||||
|
|
||||||
|
Platform.LINUX_BSD:
|
||||||
|
var output = []
|
||||||
|
OS.execute("ps", ["-o", "pid=", "-p", snbx_pid], output)
|
||||||
|
Debug.logclr("ps: " + str(output), Color.DIM_GRAY)
|
||||||
|
return not output[0].is_empty()
|
||||||
|
|
||||||
|
Platform.MACOS:
|
||||||
|
var output = []
|
||||||
|
OS.execute("ps", ["-o", "pid=", "-p", snbx_pid], output)
|
||||||
|
Debug.logclr("ps: " + str(output), Color.DIM_GRAY)
|
||||||
|
return not output[0].is_empty()
|
||||||
|
|
||||||
|
_:
|
||||||
|
assert(false, "Platform is not supported")
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
|
||||||
func _exit_tree() -> void:
|
func _exit_tree() -> void:
|
||||||
kill_sandbox()
|
kill_sandbox()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue