fix(nixos): avoid blocking guest startup on steamcmd
This commit is contained in:
@@ -65,6 +65,13 @@
|
||||
default = [ ];
|
||||
description = "TCP ports opened for the game service.";
|
||||
};
|
||||
|
||||
startupTimeout = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "15min";
|
||||
example = "30min";
|
||||
description = "Time systemd allows SteamCMD update and server startup to complete.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
@@ -138,12 +145,14 @@
|
||||
WorkingDirectory = "-${service.steamDir}";
|
||||
ExecStartPre = "+${prepareScript}";
|
||||
ExecStart = updateScript;
|
||||
TimeoutStartSec = service.startupTimeout;
|
||||
};
|
||||
};
|
||||
|
||||
${service.serviceName} = {
|
||||
description = "${service.serviceName} game server";
|
||||
after = [
|
||||
"multi-user.target"
|
||||
"network-online.target"
|
||||
"steamcmd-${service.serviceName}-update.service"
|
||||
];
|
||||
@@ -160,6 +169,7 @@
|
||||
];
|
||||
ExecStart = startScript;
|
||||
Restart = "on-failure";
|
||||
TimeoutStartSec = service.startupTimeout;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -134,6 +134,16 @@ let
|
||||
default = { };
|
||||
description = "NixOS module imported into the guest interior.";
|
||||
};
|
||||
startupTimeout = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "10min";
|
||||
example = "30min";
|
||||
description = ''
|
||||
Time the host waits for this guest to finish booting before treating
|
||||
container startup as failed.
|
||||
'';
|
||||
};
|
||||
|
||||
limits = {
|
||||
memory = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
@@ -223,6 +233,7 @@ let
|
||||
wants = [ bridgeDevice ];
|
||||
|
||||
serviceConfig = lib.filterAttrs (_: v: v != null) {
|
||||
TimeoutStartSec = lib.mkForce cfg.startupTimeout;
|
||||
MemoryMax = cfg.limits.memory;
|
||||
CPUQuota = cfg.limits.cpu;
|
||||
TasksMax = cfg.limits.tasksMax;
|
||||
|
||||
Reference in New Issue
Block a user