我有一台运行 Raspberry Pi OS 的 Raspberry Pi 5 8gb,我遇到的问题是qbittorrent-nox
,我使用 apt 安装的它在大约 1 分 30 秒后不断崩溃。
因为我有一个自动启动的服务qbittorrent-nox
,它会在 3 秒内重新启动,但重新启动很烦人,而且显然不利于播种和吸血,我想知道为什么会发生这种情况。
经过一些实验,日志中有些内容表明服务systemd
正在超时,果然,我让用户对 qbit 进行 su-ing 运行,qbittorrent-nox
似乎运行良好,无需重新启动。
日志和systemd
服务文件之前已经包含过了,我使用了样板代码,没有做太多调整,也不太理解其中的内容。
Service:
[Unit]
Description=qBittorrent Command Line Client
After=network.target
[Service]
#Do not change to "simple"
Type=forking
User=qbit
Group=qbit
ExecStart=/usr/bin/qbittorrent-nox
ExecStop=/usr/bin/killall -w qbittorrent-nox
Restart=on-failure
[Install]
WantedBy=multi-user.target
服务日志:
MAGPi@raspberrypi:~ $ journalctl -xeu qbit.service
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit qbit.service has finished with a failure.
░░
░░ The job identifier is 152795 and the job result is failed.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Consumed 1.685s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit qbit.service has finished with a failure.
░░
░░ Defined-By: systemd
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit qbit.service has finished with a failure.
░░
░░ The job identifier is 152795 and the job result is failed.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Consumed 1.685s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit qbit.service completed and consumed the indicated resources.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Scheduled restart job, restart counter is at 1784.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ Automatic restarting of the unit qbit.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Dec 18 00:05:26 raspberrypi systemd[1]: Stopped qbit.service - qBittorrent Command Line Client.
░░ Subject: A stop job for unit qbit.service has finished
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A stop job for unit qbit.service has finished.
░░
░░ The job identifier is 152877 and the job result is done.
Dec 18 00:05:26 raspberrypi systemd[1]: qbit.service: Consumed 1.685s CPU time.
░░ Subject: Resources consumed by unit runtime
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit qbit.service completed and consumed the indicated resources.
Dec 18 00:05:26 raspberrypi systemd[1]: Starting qbit.service - qBittorrent Command Line Client...
░░ Subject: A start job for unit qbit.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit qbit.service has begun execution.
░░
░░ The job identifier is 152877.
```
答案1
服务保持“激活”状态,直到 systemd 收到某种就绪指示(即,服务需要指示它已加载其配置、打开其套接字等)。
告诉Type=forking
systemd 期望程序将“守护进程化”或“分叉到后台”;这将被视为服务已准备就绪的迹象。但由于 qbittorrent-nox 不会这样做,因此服务将永远处于“激活”状态,直到超时。
添加--daemon
选项(首选),或更改Type=forking
为Type=simple
。