【发布时间】:2014-02-27 19:42:38
【问题描述】:
我正在开发一个运行 Raspbian 并运行 Node.js 应用程序的 Raspberry Pi,并尝试在 Pi 启动时启动它。我找到了几个例子,但我似乎无法让它工作。我当前的代码是:
#! /bin/sh
# /etc/init.d/MyApp
### BEGIN INIT INFO
# Provides: MyApp.js
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts MyApp.js
# Description: Start / stop MyApp.js at boot / shutdown.
### END INIT INFO
# If you want a command to always run, put it here
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting MyApp.js"
# run application you want to start
node /home/pi/app/MyApp/MyApp.js
;;
stop)
echo "Stopping MyApp.js"
# kill application you want to stop
killall MyApp.js
;;
*)
echo "Usage: /etc/init.d/MyApp {start|stop}"
exit 1
;;
esac
exit 0
我在 etc/init.d 文件夹中有这个,运行 chmod +x /etc/init.d/MyApp,我可以手动运行它,然后运行 sudo update-rc.d MyApp defaults,重新启动,脚本永远不会运行。我查看了一些不同的示例,进行了调整,但仍然没有运气。
【问题讨论】: