Files
sentinel/main.rb
T

36 lines
1.1 KiB
Ruby
Raw Normal View History

2026-06-07 11:05:26 +08:00
# <<*>> -^v- SNOWARE APPLICATION
# usage: MINESENTINEL mainloop.
# author: S.A.
# time: 2026-06-07
# license: All rights received.
require_relative 'server_status_detector'
require_relative 'method_executor' # 日志系统在此时初始化
MethodExecutor.record("info", "mainloop", "MineSentinel started, entering mainloop.")
# Functional mainloop.
def main
chkrslt = ServerStatusDetector::MinecraftServer.self_diag
if chkrslt[:type]
MethodExecutor.record("debug", "mainloop", "Server health check passed.")
else
MethodExecutor.record("warn", "mainloop", "Server health check FAILED: #{chkrslt[:message]}")
for operation in chkrslt[:operation]
if operation == "Record"
# 消息已在 self_diag 中生成,这里仅记录操作
MethodExecutor.record("warn", "mainloop", "Action: Record -> Server died!")
elsif operation == "ForceResetServerProcess"
MethodExecutor.record("info", "mainloop", "Action: ForceResetServerProcess triggered.")
MethodExecutor.reset_minecraft_server
end
end
end
end
while true
sleep 10
main
end