簡體   English   中英

嘗試運行服務時 systemctl Exec 格式錯誤

[英]systemctl Exec format error when trying to run service

目前我想在我的 vps 上運行我的專用服務器。 當我運行systemctl start csgo.service它給我錯誤Load: error (Reason: Exec format error)當我運行systemctl status csgo.service它給我/lib/systemd/system/csgo.service:12: Executable path is not absolute: killall -TERM srcds_linux 以下是我嘗試運行的服務文件,因為它顯示格式錯誤,我是否犯了任何錯誤?

[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

我的專用服務器文件位於 /home/steam/steamcmd/csgo

引用有關單元文件的手冊

請注意,不直接支持 shell 命令行。 如果要使用 shell 命令行,則需要將它們顯式傳遞給某種 shell 實現。

示例: ExecStart=sh -c 'dmesg | tac' ExecStart=sh -c 'dmesg | tac'

您需要像這樣使用sh或找出killall可執行文件的實際路徑,例如

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

或者

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

順便說一句,這不是最好的ExecStop命令。 它會無情地殺死所有srcds_linux可執行文件,無論它們是否與此服務相關。 沒有ExecStop命令將使 systemd 自行終止服務:

請注意,為此設置指定僅要求服務終止的命令通常是不夠的(例如,通過為它排隊某種形式的終止信號),但不等待它這樣做。 由於服務的剩余進程在命令退出后立即按照上文所述的 KillMode= 和 KillSignal= 被殺死,這可能不會導致完全停止。 因此,指定的命令應該是同步操作,而不是異步操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM