05-06-2015, 08:56 PM
Hi everybody!
I got a new root server with Debian 8 stable, which has the new and awesome systemd init system.
It is not only an init system, it is also a process supervisor. So i wanted to manage my cs go dedicated server
with it. Seems like nobody ever tried it and i think i found a very handy solution for this.
So here it is...
Whenever you see a # before the command it means to execute it as root. When you see a $ it means run as your normal user. We use the systemd user mode. This way you can start/stop/restart your server and see the logs without root.
Let the systemd user instance run even if not logged in. Replace <user>. Run as root:
# loginctl enable-linger <user>
I assume you have installed steamcmd and the csgo dedicated server by now. If not here is the howto: link
Install the service file:
$ cd
$ mkdir -p .config/systemd/user
$ nano .config/systemd/user/csgo.service
Replace <steamcmd_path> with the full path to your steamcmd folder in your home directory (e.g. "/home/gs/steamcmd") and replace <csgo_path> with the full path to your csgo folder (e.g. "/home/gs/csgo")
Reload the systemd user instance so that it loads the new service. This should be done
everytime you change something in the service file too:
$ systemctl --user daemon-reload
The server is updatet in ExecStartPre with steamcmd.sh. The default timeout for this is 90 seconds.
With TimeoutStartSec=0 i disabled the timeout, because you cannot know how long the download will take
and it should wait as long as it takes. After that ExecStart is run and the service status changes from "activating" to "active".
It will be restartet on every type of crash or normal exit. If there is an update for the server it shuts itself down normally (because of the -autoupdate parameter), will be restartet und updatet with the ExecStartPre command.
This is the update script needed for steamcmd.sh. Again replace <csgo_path>.
Ok. This should be it
Enable your service to start on boot:
$ systemctl --user enable csgo
Start your server with:
$ systemctl --user start csgo
Stop your server with:
$ systemctl --user stop csgo
Restart your server with:
$ systemctl --user restart csgo
See the status of your server with:
$ systemctl --user status csgo
Another cool thing is the journal. Everything the server prints to the standard output lands there. If you run the
command "systemctl --user status" you see the last 10 log entries from it. By default the journal is runtime only.
So you see only the messages from this boot. You can change that to permanent journal,
but that is beyond this howto for now.
You can view it with:
$ journalctl --user-unit csgo
If you want to see the output of the server while playing you can look into the journal in follow mode:
$ journalctl -f --user-unit csgo
Thats it! Have fun!
I got a new root server with Debian 8 stable, which has the new and awesome systemd init system.
It is not only an init system, it is also a process supervisor. So i wanted to manage my cs go dedicated server
with it. Seems like nobody ever tried it and i think i found a very handy solution for this.
So here it is...
Whenever you see a # before the command it means to execute it as root. When you see a $ it means run as your normal user. We use the systemd user mode. This way you can start/stop/restart your server and see the logs without root.
Let the systemd user instance run even if not logged in. Replace <user>. Run as root:
# loginctl enable-linger <user>
I assume you have installed steamcmd and the csgo dedicated server by now. If not here is the howto: link
Install the service file:
$ cd
$ mkdir -p .config/systemd/user
$ nano .config/systemd/user/csgo.service
Code:
[Unit]
Description=Counter-Strike Global Offensive Dedicated Server
Documentation=https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers
After=network.target
[Service]
WorkingDirectory=<csgo_path>
Environment="LD_LIBRARY_PATH=<csgo_path>:<csgo_path>/bin"
ExecStartPre=<steamcmd_path>/steamcmd.sh +runscript <steamcmd_path>/csgo_update
ExecStart=<csgo_path>/srcds_linux -autoupdate -game csgo -usercon -tickrate 128 -port 27015 \
+game_type 0 +game_mode 0 +mapgroup mg_active +map de_dust2
TimeoutStartSec=0
Restart=always
[Install]
WantedBy=default.target
Replace <steamcmd_path> with the full path to your steamcmd folder in your home directory (e.g. "/home/gs/steamcmd") and replace <csgo_path> with the full path to your csgo folder (e.g. "/home/gs/csgo")
Reload the systemd user instance so that it loads the new service. This should be done
everytime you change something in the service file too:
$ systemctl --user daemon-reload
The server is updatet in ExecStartPre with steamcmd.sh. The default timeout for this is 90 seconds.
With TimeoutStartSec=0 i disabled the timeout, because you cannot know how long the download will take
and it should wait as long as it takes. After that ExecStart is run and the service status changes from "activating" to "active".
It will be restartet on every type of crash or normal exit. If there is an update for the server it shuts itself down normally (because of the -autoupdate parameter), will be restartet und updatet with the ExecStartPre command.
This is the update script needed for steamcmd.sh. Again replace <csgo_path>.
Code:
login anonymous
force_install_dir <csgo_path>/
app_update 740
exit
Ok. This should be it
Enable your service to start on boot:
$ systemctl --user enable csgo
Start your server with:
$ systemctl --user start csgo
Stop your server with:
$ systemctl --user stop csgo
Restart your server with:
$ systemctl --user restart csgo
See the status of your server with:
$ systemctl --user status csgo
Code:
$ systemctl --user status csgo
● csgo.service - Counter-Strike Global Offensive Dedicated Server
Loaded: loaded (/home/gs/.config/systemd/user/csgo.service; enabled)
Active: active (running) since Wed 2015-05-06 10:25:44 CEST; 1h 54min ago
Docs: https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers
Main PID: 661 (srcds_linux)
CGroup: /user.slice/user-1001.slice/user@1001.service/csgo.service
└─661 /home/gs/csgo/srcds_linux -autoupdate -game csgo -stringtables -usercon -tickrate 128...
May 06 10:25:49 tomate srcds_linux[661]: mp_roundtime_defuse - 0
May 06 10:25:50 tomate srcds_linux[661]: mp_roundtime_hostage [S_API FAIL] SteamAPI_Init() failed;...led.
May 06 10:25:50 tomate srcds_linux[661]: Setting breakpad minidump AppID = 730
May 06 10:25:50 tomate srcds_linux[661]: dlopen failed trying to load:
May 06 10:25:50 tomate srcds_linux[661]: /home/gs/.steam/sdk32/steamclient.so
May 06 10:25:50 tomate srcds_linux[661]: with error:
May 06 10:25:50 tomate srcds_linux[661]: /home/gs/.steam/sdk32/steamclient.so: cannot open shared ...tory
May 06 10:25:50 tomate srcds_linux[661]: Looking up breakpad interfaces from steamclient
May 06 10:25:50 tomate srcds_linux[661]: Calling BreakpadMiniDumpSystemInit
May 06 10:25:50 tomate srcds_linux[661]: Setting breakpad minidump AppID = 740
Hint: Some lines were ellipsized, use -l to show in full.
Another cool thing is the journal. Everything the server prints to the standard output lands there. If you run the
command "systemctl --user status" you see the last 10 log entries from it. By default the journal is runtime only.
So you see only the messages from this boot. You can change that to permanent journal,
but that is beyond this howto for now.
You can view it with:
$ journalctl --user-unit csgo
If you want to see the output of the server while playing you can look into the journal in follow mode:
$ journalctl -f --user-unit csgo
Thats it! Have fun!