Scheduled daily restart of the world (#202)

Settings/restart-schedule.json (Settings, Startup) holds a local time and a countdown.
The Rust world supervisor asks the world for 'server restart <seconds>' once that time has
passed (by at most 15 minutes, for a world that ran before it), and starts the world
again when it exits with RESTART_EXIT_CODE; the database and auth keep running. While it
is under way (.state/scheduled-restart) the status says so and the Manager does not take
the down world for a crash. Extra worlds follow their server's schedule. Repacks with the
Python supervisor do not run the schedule; the card says the server needs an update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Opus 5.5 committed 2026-11-15 20:26:14 +05:00
1 parent 20657df203
commit 260d10b729
17 files changed
+395 -19

No files matched your search

+50 -2
View File
@@ -350,6 +350,8 @@ struct StatusView {
observed: Observed,
busy: bool,
path_exists: bool,
/// A scheduled restart is under way: a world that is down for a few minutes did not crash.
scheduled_restart: bool,
}
/// Where the Manager keeps its own state (server list, logs). `%LOCALAPPDATA%` on Windows, the XDG data folder elsewhere.
@@ -548,9 +550,12 @@ async fn server_status(
let root = path_of(&state, &id)?;
let busy = state.busy.lock().map(|b| b.contains(&id)).unwrap_or(false);
let path_exists = root.is_dir();
let observed = tauri::async_runtime::spawn_blocking(move || {
let (observed, scheduled_restart) = tauri::async_runtime::spawn_blocking(move || {
let ports = layout::read_ports(&root);
process::observe(&root, &ports)
(
process::observe(&root, &ports),
coa_core::launcher::schedule::under_way(&root),
)
})
.await
.map_err(|e| Error::Invalid(e.to_string()))?;
@@ -558,6 +563,7 @@ async fn server_status(
observed,
busy,
path_exists,
scheduled_restart,
})
}
@@ -1238,6 +1244,46 @@ async fn realm_select(
result
}
#[derive(serde::Serialize)]
struct RestartScheduleView {
schedule: coa_core::launcher::schedule::RestartSchedule,
/// The server ships the Rust world supervisor that carries out the schedule.
supported: bool,
}
#[tauri::command]
async fn restart_schedule(
state: State<'_, AppState>,
id: String,
) -> std::result::Result<RestartScheduleView, UiError> {
let root = path_of(&state, &id)?;
blocking(move || {
Ok(RestartScheduleView {
schedule: coa_core::launcher::schedule::load(&root),
supported: root.join("Scripts/coa-launcher.exe").is_file(),
})
})
.await
}
/// Restart the world every day at the owner's local time; the running supervisor reads it within a minute.
#[tauri::command]
async fn restart_schedule_save(
state: State<'_, AppState>,
id: String,
schedule: coa_core::launcher::schedule::RestartSchedule,
) -> std::result::Result<RestartScheduleView, UiError> {
let root = path_of(&state, &id)?;
let _guard = BusyGuard::acquire(&state, &id)?;
blocking(move || {
Ok(RestartScheduleView {
schedule: coa_core::launcher::schedule::save(&root, &schedule)?,
supported: root.join("Scripts/coa-launcher.exe").is_file(),
})
})
.await
}
#[tauri::command]
async fn mysql_custom(
state: State<'_, AppState>,
@@ -3034,6 +3080,8 @@ pub fn run() {
realm_rename,
mysql_custom,
mysql_custom_save,
restart_schedule,
restart_schedule_save,
check_database,
repair_server,
module_set_enabled,