fix: something
This commit is contained in:
@@ -33,6 +33,46 @@ pub struct PortMap {
|
||||
pub protocol: String, // "tcp" or "udp"
|
||||
}
|
||||
|
||||
/// Per-game runtime knobs supplied by the panel. Mirrored into Docker labels so
|
||||
/// they survive a daemon restart (see `docker::container`).
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct ServerRuntime {
|
||||
/// Mount point of the data directory inside the container. `None` means
|
||||
/// "derive it from the image".
|
||||
pub data_mount_path: Option<String>,
|
||||
/// In-game command that shuts the server down cleanly (e.g. `stop`, `quit`).
|
||||
pub stop_command: Option<String>,
|
||||
/// Total budget for a graceful shutdown before the container gets killed.
|
||||
pub stop_timeout_seconds: Option<i64>,
|
||||
}
|
||||
|
||||
impl ServerRuntime {
|
||||
pub fn from_request(
|
||||
data_mount_path: String,
|
||||
stop_command: String,
|
||||
stop_timeout_seconds: i32,
|
||||
) -> Self {
|
||||
Self {
|
||||
data_mount_path: non_empty(data_mount_path),
|
||||
stop_command: non_empty(stop_command),
|
||||
stop_timeout_seconds: if stop_timeout_seconds > 0 {
|
||||
Some(stop_timeout_seconds as i64)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn non_empty(value: String) -> Option<String> {
|
||||
let trimmed = value.trim();
|
||||
if trimmed.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(trimmed.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ServerSpec {
|
||||
pub uuid: String,
|
||||
@@ -46,6 +86,8 @@ pub struct ServerSpec {
|
||||
pub data_path: PathBuf,
|
||||
pub state: ServerState,
|
||||
pub container_id: Option<String>,
|
||||
#[serde(default)]
|
||||
pub runtime: ServerRuntime,
|
||||
}
|
||||
|
||||
impl ServerSpec {
|
||||
|
||||
Reference in New Issue
Block a user