Keystone CMS 系统启动时无法运行。问题可能出在这个init.d
启动脚本中。我设置了权限,但是还是有问题。
$ sudo systemctl daemon-reload
$ sudo service keystone start
Job for keystone.service failed. See 'systemctl status keystone.service' and 'journalctl -xn' for details.
$ sudo service keystone status
● keystone.service - SYSV: Keystone server daemon
Loaded: loaded (/etc/init.d/keystone)
Active: failed (Result: exit-code) since Thu 2016-10-13 07:39:12 UTC; 16s ago
Process: 2785 ExecStart=/etc/init.d/keystone start (code=exited, status=203/EXEC)
Main PID: 2698 (code=exited, status=216/GROUP)
Oct 13 07:39:12 test-vm systemd[2785]: Failed at step EXEC spawning /etc/init.d/keystone: Exec format error
Oct 13 07:39:12 test-vm systemd[1]: keystone.service: control process exited, code=exited status=203
Oct 13 07:39:12 test-vm systemd[1]: Failed to start SYSV: Keystone server daemon.
Oct 13 07:39:12 test-vm systemd[1]: Unit keystone.service entered failed state.
可能是脚本本身,它是创建的从模板。我也在考虑将其链接到/etc/rc?.d
目录之一。
我使用的是 Debian 8.6
/etc/init.d/keystone
:
Subsystem file for "Keystone" server
#
# chkconfig: 2345 95 05
# description: Keystone server daemon
RETVAL=0
prog="keystone"
start() {
echo -n $"Starting $prog:"
cd /home/user/keystone
/opt/bitnami/nodejs/bin/node /home/user/keystone/keystone.js
RETVAL=$?
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/$prog
echo
}
stop() {
echo -n $"Stopping $prog:"
killproc $prog -TERM
RETVAL=$?
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/$prog
echo
}
reload() {
echo -n $"Reloading $prog:"
killproc $prog -HUP
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
condrestart)
if [ -f /var/lock/subsys/$prog ] ; then
stop
# avoid race
sleep 3
start
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
答案1
进程:2785 ExecStart=/etc/init.d/keystone start (code=exited, status=203/EXEC) …… 10 月 13 日 07:39:12 test-vm systemd[2785]:在步骤 EXEC 生成 /etc/init.d/keystone 时失败:Exec 格式错误
……这是完全正确的。您的文件不是可执行脚本。它缺少翻译。它也不是rc
Debian 政策为旧的 van Smoorenburg 脚本规定的正确形式,因此systemd 在其描述中添加了前缀“ SYSV:
”(而不是“ ”)。LSB:
但修复它也是浪费时间。把它扔掉。编写一个systemd服务单元。
[单元] 描述=Keystone CMS 文档=http://unix.stackexchange.com/a/316168/5132 [服务] 工作目录=/home/用户/keystone ExecStart=/opt/bitnami/nodejs/bin/node /home/user/keystone/keystone.js [安装] WantedBy=多用户.target