早上好,
我们正在尝试在 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/startCustomService可以在 PIZero 上手动启动。
有什么建议么?
问候,丹尼尔
答案1
尝试添加工作目录。
WorkingDirectory=/usr/local/etc/