user10750338
user10750338

Reputation:

systemctl Exec format error when trying to run service

Currently I wanted to run my dedicated server on my vps. When I run system systemctl start csgo.service it gives me error Load: error (Reason: Exec format error) when I run systemctl status csgo.service it gives me /lib/systemd/system/csgo.service:12: Executable path is not absolute: killall -TERM srcds_linux. Below are the service file that I am trying to run, am I making any mistake since it says format error?

[Unit]
Description=CSGO Server
[Service]
Type=simple
User=steam
Group=steam
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
ExecStart=/home/steam/steamcmd/csgo/srcds_run -game csgo -console -usercon +game_type 0 +game_mode 1 -tickrate 128 +mapgroup mg_active +map de_dust2 +sv_setsteamaccount GsltKeyHere -net_port_try 1 
ExecStop=killall -TERM srcds_linux
[Install]
WantedBy=multi-user.target

My dedicated server files are inside /home/steam/steamcmd/csgo

Upvotes: 1

Views: 12202

Answers (1)

AKX
AKX

Reputation: 168863

Quoting the manual on unit files:

Note that shell command lines are not directly supported. If shell command lines are to be used, they need to be passed explicitly to a shell implementation of some kind.

Example: ExecStart=sh -c 'dmesg | tac'

You'll need to either use sh like that or figure out the actual path to your killall executable, e.g.

[Unit]
ExecStop=sh -c 'killall -TERM srcds_linux'

or

[Unit]
ExecStop=/sbin/killall -TERM srcds_linux

As an aside, that's not the best of ExecStop commands; it'll ruthlessly kill all srcds_linux executables, no matter if they're related to this service or not. Having no ExecStop command will have systemd terminate the service by itself:

Note that it is usually not sufficient to specify a command for this setting that only asks the service to terminate (for example, by queuing some form of termination signal for it), but does not wait for it to do so. Since the remaining processes of the services are killed according to KillMode= and KillSignal= as described above immediately after the command exited, this may not result in a clean stop. The specified command should hence be a synchronous operation, not an asynchronous one.

Upvotes: 1

Related Questions