tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/terraria: Wait for daemon to stop
Janne Heß
7 years ago
943786ec
f0d6e22b
+13
-3
1 changed file
expand all
collapse all
unified
split
nixos
modules
services
games
terraria.nix
+13
-3
nixos/modules/services/games/terraria.nix
···
18
(boolFlag "secure" cfg.secure)
19
(boolFlag "noupnp" cfg.noUPnP)
20
];
0
0
0
0
0
0
0
0
0
0
21
in
22
{
23
options = {
···
124
125
serviceConfig = {
126
User = "terraria";
127
-
Type = "oneshot";
128
-
RemainAfterExit = true;
129
ExecStart = "${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock new -d ${pkgs.terraria-server}/bin/TerrariaServer ${concatStringsSep " " flags}";
130
-
ExecStop = "${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock send-keys Enter \"exit\" Enter";
131
};
132
133
postStart = ''
···
18
(boolFlag "secure" cfg.secure)
19
(boolFlag "noupnp" cfg.noUPnP)
20
];
21
+
stopScript = pkgs.writeScript "terraria-stop" ''
22
+
#!${pkgs.runtimeShell}
23
+
24
+
if ! [ -d "/proc/$1" ]; then
25
+
exit 0
26
+
fi
27
+
28
+
${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock send-keys Enter exit Enter
29
+
${getBin pkgs.coreutils}/bin/tail --pid="$1" -f /dev/null
30
+
'';
31
in
32
{
33
options = {
···
134
135
serviceConfig = {
136
User = "terraria";
137
+
Type = "forking";
138
+
GuessMainPID = true;
139
ExecStart = "${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock new -d ${pkgs.terraria-server}/bin/TerrariaServer ${concatStringsSep " " flags}";
140
+
ExecStop = "${stopScript} $MAINPID";
141
};
142
143
postStart = ''