diff options
author | Joachim F <joachifm@users.noreply.github.com> | 2018-08-20 20:23:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-20 20:23:34 +0000 |
commit | 69d3bdfa1621d58c1257cb18f831799b271f5c6d (patch) | |
tree | ae302546787f9d3ed9ac39855e3d5496bce64aad /nixos/modules | |
parent | 70a0c15054b63bb5eb06c892a3f0bf8f58215188 (diff) | |
parent | 943786eccf393f9539e00104f65271c88baf83fe (diff) | |
download | nixlib-69d3bdfa1621d58c1257cb18f831799b271f5c6d.tar nixlib-69d3bdfa1621d58c1257cb18f831799b271f5c6d.tar.gz nixlib-69d3bdfa1621d58c1257cb18f831799b271f5c6d.tar.bz2 nixlib-69d3bdfa1621d58c1257cb18f831799b271f5c6d.tar.lz nixlib-69d3bdfa1621d58c1257cb18f831799b271f5c6d.tar.xz nixlib-69d3bdfa1621d58c1257cb18f831799b271f5c6d.tar.zst nixlib-69d3bdfa1621d58c1257cb18f831799b271f5c6d.zip |
Merge pull request #44631 from dasJ/terraria
nixos/terraria: Wait for daemon to stop
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/games/terraria.nix | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nixos/modules/services/games/terraria.nix b/nixos/modules/services/games/terraria.nix index ddf17599296a..31f8edca20ce 100644 --- a/nixos/modules/services/games/terraria.nix +++ b/nixos/modules/services/games/terraria.nix @@ -18,6 +18,16 @@ let (boolFlag "secure" cfg.secure) (boolFlag "noupnp" cfg.noUPnP) ]; + stopScript = pkgs.writeScript "terraria-stop" '' + #!${pkgs.runtimeShell} + + if ! [ -d "/proc/$1" ]; then + exit 0 + fi + + ${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock send-keys Enter exit Enter + ${getBin pkgs.coreutils}/bin/tail --pid="$1" -f /dev/null + ''; in { options = { @@ -124,10 +134,10 @@ in serviceConfig = { User = "terraria"; - Type = "oneshot"; - RemainAfterExit = true; + Type = "forking"; + GuessMainPID = true; ExecStart = "${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock new -d ${pkgs.terraria-server}/bin/TerrariaServer ${concatStringsSep " " flags}"; - ExecStop = "${getBin pkgs.tmux}/bin/tmux -S /var/lib/terraria/terraria.sock send-keys Enter \"exit\" Enter"; + ExecStop = "${stopScript} $MAINPID"; }; postStart = '' |