diff options
author | Janne Heß <janne@hess.ooo> | 2018-08-07 19:57:35 +0200 |
---|---|---|
committer | Janne Heß <janne@hess.ooo> | 2018-08-20 21:41:29 +0200 |
commit | 943786eccf393f9539e00104f65271c88baf83fe (patch) | |
tree | 4adf7c3180bb68a803412f838d4d93c72e065b49 /nixos/modules/services/games/terraria.nix | |
parent | f0d6e22b7f0d89f4474abd41b917a18cec128529 (diff) | |
download | nixpkgs-943786eccf393f9539e00104f65271c88baf83fe.tar nixpkgs-943786eccf393f9539e00104f65271c88baf83fe.tar.gz nixpkgs-943786eccf393f9539e00104f65271c88baf83fe.tar.bz2 nixpkgs-943786eccf393f9539e00104f65271c88baf83fe.tar.lz nixpkgs-943786eccf393f9539e00104f65271c88baf83fe.tar.xz nixpkgs-943786eccf393f9539e00104f65271c88baf83fe.tar.zst nixpkgs-943786eccf393f9539e00104f65271c88baf83fe.zip |
nixos/terraria: Wait for daemon to stop
Diffstat (limited to 'nixos/modules/services/games/terraria.nix')
-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 ddf17599296..31f8edca20c 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 = '' |