systemdは私のデーモンを再起動し続けます

systemdは私のデーモンを再起動し続けます

WiFi / Ethernetを介してRaspberry PiをUSBトンネルとして使用する予定なので、udevを自動的にバインドし、カーネルモジュールをコンパイルして挿入するスクリプトを作成しましたが、デーモンに閉じ込められました。以前の方法は、rc.localでデーモンが起動された古いシステムで正しく機能しました。

私が追加したもの/etc/systemd/system/usbipd.service:

[Unit]
Description=usbip host daemon
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
Restart=always
ExecStart=/usr/sbin/usbipd -D

[Install]
WantedBy=multi-user.target

システムログから得た内容:

Sep  9 23:47:25 raspi-conn systemd[1]: Started usbip host daemon.
...
Sep  9 23:47:26 raspi-conn systemd[1]: usbipd.service: Succeeded.
Sep  9 23:47:27 raspi-conn systemd[1]: usbipd.service: Scheduled restart job, restart counter is at 1.
...
Sep  9 23:47:27 raspi-conn systemd[1]: Stopped usbip host daemon.
Sep  9 23:47:27 raspi-conn systemd[1]: Started usbip host daemon.
...
Sep  9 23:47:27 raspi-conn usbipd: usbipd: info: starting usbipd (usbip-utils 2.0)
Sep  9 23:47:27 raspi-conn usbipd: usbipd: info: listening on 0.0.0.0:3240
Sep  9 23:47:27 raspi-conn usbipd: usbipd: info: listening on :::3240
Sep  9 23:47:27 raspi-conn usbipd: usbipd: info: shutting down usbipd
Sep  9 23:47:27 raspi-conn systemd[1]: usbipd.service: Succeeded.
...
Sep  9 23:47:27 raspi-conn systemd[1]: usbipd.service: Scheduled restart job, restart counter is at 2.
...
Sep  9 23:47:27 raspi-conn systemd[1]: Stopped usbip host daemon.
...
Sep  9 23:47:27 raspi-conn systemd[1]: Started usbip host daemon.
...
Sep  9 23:47:28 raspi-conn usbipd: usbipd: info: starting usbipd (usbip-utils 2.0)
Sep  9 23:47:28 raspi-conn usbipd: usbipd: info: listening on 0.0.0.0:3240
Sep  9 23:47:28 raspi-conn usbipd: usbipd: info: listening on :::3240
...
Sep 10 08:15:17 raspi-conn systemd[1]: usbipd.service: State 'stop-sigterm' timed out. Killing.
Sep 10 08:15:17 raspi-conn systemd[1]: usbipd.service: Killing process 560 (usbipd) with signal SIGKILL.
Sep 10 08:15:17 raspi-conn systemd[1]: usbipd.service: Failed with result 'timeout'.
Sep 10 08:15:17 raspi-conn systemd[1]: usbipd.service: Scheduled restart job, restart counter is at 3.
Sep 10 08:15:17 raspi-conn systemd[1]: Stopped usbip host daemon.
Sep 10 08:15:17 raspi-conn systemd[1]: Started usbip host daemon.
Sep 10 08:15:17 raspi-conn usbipd: usbipd: info: starting usbipd (usbip-utils 2.0)
Sep 10 08:15:17 raspi-conn usbipd: usbipd: info: listening on 0.0.0.0:3240
Sep 10 08:15:17 raspi-conn usbipd: usbipd: info: listening on :::3240
...
Sep 10 08:16:47 raspi-conn systemd[1]: usbipd.service: State 'stop-sigterm' timed out. Killing.
Sep 10 08:16:47 raspi-conn systemd[1]: usbipd.service: Killing process 1449 (usbipd) with signal SIGKILL.
Sep 10 08:16:47 raspi-conn systemd[1]: usbipd.service: Failed with result 'timeout'.
Sep 10 08:16:47 raspi-conn systemd[1]: usbipd.service: Scheduled restart job, restart counter is at 4.
Sep 10 08:16:47 raspi-conn systemd[1]: Stopped usbip host daemon.
Sep 10 08:16:47 raspi-conn systemd[1]: Started usbip host daemon.
Sep 10 08:16:47 raspi-conn usbipd: usbipd: info: starting usbipd (usbip-utils 2.0)
Sep 10 08:16:47 raspi-conn usbipd: usbipd: info: listening on 0.0.0.0:3240
Sep 10 08:16:47 raspi-conn usbipd: usbipd: info: listening on :::3240
...
Sep 10 08:18:18 raspi-conn systemd[1]: usbipd.service: State 'stop-sigterm' timed out. Killing.
Sep 10 08:18:18 raspi-conn systemd[1]: usbipd.service: Killing process 1482 (usbipd) with signal SIGKILL.
Sep 10 08:18:18 raspi-conn systemd[1]: usbipd.service: Failed with result 'timeout'.
Sep 10 08:18:18 raspi-conn systemd[1]: usbipd.service: Scheduled restart job, restart counter is at 5.
Sep 10 08:18:18 raspi-conn systemd[1]: Stopped usbip host daemon.
Sep 10 08:18:18 raspi-conn systemd[1]: Started usbip host daemon.
Sep 10 08:18:18 raspi-conn usbipd: usbipd: info: starting usbipd (usbip-utils 2.0)
Sep 10 08:18:18 raspi-conn usbipd: usbipd: info: listening on 0.0.0.0:3240
Sep 10 08:18:18 raspi-conn usbipd: usbipd: info: listening on :::3240

私はシステム内部の経験が少なく、デバッグ方法もわかりません。プロセスが停止して再起動する明確な理由はありません。 systemdがプロセスステータスを取得できないようです。

答え1

あなたの定義が定義Type=と一致しません。ExecStart=

Type=Simpleプログラムがバックグラウンドに分岐しないことを期待するように設定しましたが、-Dプロセスをバックグラウンドに分岐するパラメータを使用します。

-Dパラメータを省略するかType=forking

私は最初のオプションを好む。これはsystemdがロギングを処理できるからです。

関連情報