我目前正在尝试在我的 Ubuntu 服务器打开时启动 Luigid,我尝试了几种技术,包括 rc.local、cronjob(@reboot)、upstart、systemd,但它们似乎都没有工作。
我应该指出,如果我手动执行该命令,该命令运行良好,我只需要它在启动时运行。在这一点上,我真的不担心我用哪种方式让它工作,所以这里有一些我尝试过的东西 -
克朗:
用过的
sudo crontab -e
并输入
@reboot luigid --background --logdir /home/myuser/luigilog
系统化:
我在 /usr/bin 中有一个名为 luigid 的脚本,其中包含以下内容,它被标记为可执行文件,我已经尝试过使用和不使用“exit 0”的情况,担心可能需要正确的退出代码 -
#!/bin/sh
exec luigid --background --logdir /home/myuser/luigilog
和 /etc/systemd/system/ 中名为 luigid.service 的服务文件 -
[Unit]
Description=Luigid Service
[Service]
Type=forking
ExecStart=/usr/bin/luigid
[Install]
WantedBy=multi-user.target
我尝试过分叉(并在服务和 lugid 命令中指定 PIDfile,oneshot 和 simple 的类型都没有运气。
我已使用 -
systemctl enable luigid.service
它似乎尝试启动服务,因为使用检查状态
systemctl status luigid.service
节目
luigid.service - Luigid Service
Loaded: loaded (/etc/systemd/system/luigid.service; enabled; vendor preset: enabled)
Active: failed (Result: timeout) since Mon 2016-10-10 15:18:00 UTC; 18min ago
Oct 10 15:16:29 Analytics systemd[1]: Starting Luigid Service...
Oct 10 15:18:00 Analytics systemd[1]: luigid.service: Start operation timed out. Terminating.
Oct 10 15:18:00 Analytics systemd[1]: Failed to start Luigid Service.
Oct 10 15:18:00 Analytics systemd[1]: luigid.service: Unit entered failed state.
Oct 10 15:18:00 Analytics systemd[1]: luigid.service: Failed with result 'timeout'.
一定有一些明显的我遗漏的东西,让命令在启动时运行真的不是那么难!