/etc/systemd/system に corekeeperds.service って名前で以下の内容のファイルを作る。
[Unit] Description=Core Keeper Dedicated Server Documentation= [Service] Type=exec User=steam Group=steam TimeoutStartSec=0 Restart=always RestartSec=30s WorkingDirectory=/home/steam/Steam/steamapps/common/Core Keeper Dedicated Server/ ExecStartPre=/home/steam/steamcmd +login anonymous +app_update 1007 +app_update 1963720 +quit ExecStart=/usr/bin/env "/home/steam/Steam/steamapps/common/Core Keeper Dedicated Server/_launch.sh" SyslogIdentifier=CoreKeeperDS [Install] WantedBy=multi-user.target
※ ExecStart はバグっているので空白のあるパスを食わせるとうまく処理できない。なので /usr/bin/env 経由で文字列を食わせている。古の知識。
作ったら、
chmod 755 /etc/systemd/system/corekeeperds.service systemctl daemon-reload
して、完了。
あとは
systemctl start corekeeperds.service
でサービス開始。
systemdがプロセスを死活監視して、異常終了した場合(この辺の挙動は 後述の Note 参照)に勝手に再起動してくれるようになります。
状態は
systemctl status corekeeperds.service
で見て、
止めるときは
systemctl stop corekeeperds.service
で。(時間かかる)
Restart=on-failure で大丈夫だと思うのですが、うまく上がってこないときは always とかにした方がいいかもしれません。
Restart の各設定値の挙動については以下が詳しいです。
https://tex2e.github.io/blog/linux/systemd-restart-config
ぼっちなので、私のサーバーには Dedicated Server が落ちるほどプレイヤーが来ません。
なので Systemd への登録で、ちゃんと再起動するかどうかは確認できてない感じです。
出来なかったらごめんなさい。
Ubuntu 22.04 LTS x86_64 で構築。 CoreKeeper側で apt に依存しているっぽいので、Ubuntu でやった方が楽だと思います。 Tips Ubuntu 20 TLS でやる場合、/home/steam/Steam/ が /home/steam/.steam/ になってたと思...
[Unit]Description=Core Keeper Dedicated ServerDocumentation=[Service]Type=simpleUser=steamGroup=steamTimeoutStartSec=0Restart=on-failureRestartSec=30sWorkingDirectory=/home/steam/Steam/steamapps/common/Core Keeper Dedicated Server/ExecStartPre=/home/s...