systemd を使用してカスタムサービスを開始することはできません。 [閉じる]

systemd を使用してカスタムサービスを開始することはできません。 [閉じる]

おはようございます、

Raspberry PIZero Wirelessでカスタムサービスを開始しようとしています。私たちが使用するプログラムはUbuntu 14.04のPI3用です。 PiZeroは2017-04-10-raspbian-jessieを実行します。以下では、CUSTOM_SERVICEという名前を使用します。

成功せずにいろいろ試してみました。サービスレポートのステータスを問い合わせます。

sudo systemctl status CUSTOM_SERVICE.service
● CUSTOM_SERVICE.service - Custom service
   Loaded: loaded (/etc/systemd/system/CUSTOM_SERVICE.service; enabled)
   Active: activating (auto-restart) (Result: exit-code) since Wed 2017-04-26 14:44:40 UTC; 32s ago
  Process: 1516 ExecStart=/usr/local/etc/startCustomService (code=exited, status=203/EXEC)
 Main PID: 1516 (code=exited, status=203/EXEC)

Apr 26 14:44:40 raspberrypi systemd[1]: CUSTOM_SERVICE.service: main process exited, code=exited, status=203/EXEC
Apr 26 14:44:40 raspberrypi systemd[1]: Unit CUSTOM_SERVICE.service entered failed state.

使用コマンド:

sudo ls -l /etc/systemd/system/multi-user.target.wants/*.service

出力:

...
lrwxrwxrwx 1 root root 40 Apr 10 09:24 /etc/systemd/system/multi-user.target.wants/avahi-daemon.service -> /lib/systemd/system/avahi-daemon.service
lrwxrwxrwx 1 root root 38 Apr 26 13:53 /etc/systemd/system/multi-user.target.wants/CUSTOM_SERVICE.service -> /etc/systemd/system/CUSTOM_SERVICE.service
...

サービス単位ファイルは次のように定義されます。

more /etc/systemd/system/multi-user.target.wants/CUSTOM_SERVICE.service
[Unit]
Description=Custom service
After=network-online.target

[Service]
Type=simple
RestartSec=60
Restart=always
ExecStart=/usr/local/etc/startCustomService

[Install]
WantedBy=multi-user.target

どこ/usr/local/etc/startCustomService~として定義された

more /usr/local/etc/startCustomService
#!/bin/sh
/usr/local/sbin/customService

私が言ったように、サービスはUbuntu 14.04で正しく起動して実行されます。また、ファイル/usr/local/etc/startCustomServicePIZeroから手動で起動できます。

どんな提案がありますか?

ありがとう、ダニエル

ベストアンサー1

作業ディレクトリを追加してみてください。

WorkingDirectory=/usr/local/etc/

おすすめ記事