我正在 CentOS 7 上运行 minecraft 服务器,并使用此 systemd 服务在崩溃时重新启动它。
服务配置位于/etc/systemd/system/my_minecraft_server.service
:
[Unit]
Description=my_minecraft_server
[Service]
Type=simple
WorkingDirectory=/home/my_user/my_server/
ExecStart=/home/my_user/my_server/start.sh
User=my_user
Restart=always
Sockets=my_minecraft_server.socket
StandardInput=socket
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
套接字配置位于/etc/systemd/system/my_minecraft_server.socket
:
[Unit]
PartOf=my_minecraft_server.service
[Socket]
ListenFIFO=%t/my_minecraft_server.stdin
但在 CentOS 9 上,这不起作用:
$ sudo systemctl start my_minecraft_server.service
Job for my_minecraft_server.service failed because of unavailable resources or another system error.
See "systemctl status my_minecraft_server.service" and "journalctl -xeu my_minecraft_server.service" for details.
的输出systemctl status my_minecraft_server.service
是:
$ systemctl status my_minecraft_server.service
× my_minecraft_server.service - my_minecraft_server
Loaded: loaded (/etc/systemd/system/my_minecraft_server.service; enabled; preset: disabled)
Active: failed (Result: resources) since Fri 2024-05-03 00:36:59 EDT; 1min 9s ago
TriggeredBy: ○ my_minecraft_server.socket
CPU: 0
May 03 00:36:59 systemd[1]: my_minecraft_server.service: Scheduled restart job, restart counter is at 5.
May 03 00:36:59 systemd[1]: Stopped my_minecraft_server.
May 03 00:36:59 systemd[1]: my_minecraft_server.service: Start request repeated too quickly.
May 03 00:36:59 systemd[1]: my_minecraft_server.service: Failed with result 'resources'.
May 03 00:36:59 systemd[1]: Failed to start my_minecraft_server.
的输出journalctl -xeu my_minecraft_server.service
是:
░░ Subject: A stop job for unit my_minecraft_server.service has finished
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ A stop job for unit my_minecraft_server.service has finished.
░░
░░ The job identifier is 133423 and the job result is done.
May 03 00:36:59 systemd[1]: my_minecraft_server.service: Start request repeated too quickly.
May 03 00:36:59 systemd[1]: my_minecraft_server.service: Failed with result 'resources'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ The unit my_minecraft_server.service has entered the 'failed' state with result 'resources'.
May 03 00:36:59 systemd[1]: Failed to start my_minecraft_server.
░░ Subject: A start job for unit my_minecraft_server.service has failed
░░ Defined-By: systemd
░░ Support: https://access.redhat.com/support
░░
░░ A start job for unit my_minecraft_server.service has finished with a failure.
░░
░░ The job identifier is 133423 and the job result is failed.
我不知道为什么会失败。start.sh
如果我手动运行脚本,它会正确运行。为什么我的服务不再工作了?