我已经使用 Intel Galileo 玩了一段时间,并创建了一个 node.js 和 express 服务器,我一直在使用它。我现在正试图让我的命令在机器启动时触发,但我很挣扎。我使用了下面的方法,让我知道哪些日志等有用,我可以提供它们:
# check its working
/home/root/node_modules/forever/bin/forever start -m 1 -l /home/root/server_log.log -o /home/root/server_log.log -e err.log /home/root/server.js
# set up autostart
vi /etc/init.d/express-server.sh
Add:
#! /bin/sh
case "$1" in
start)
echo "Starting express server"
/home/root/node_modules/forever/bin/forever start -m 1 -l /home/root/server_log.log -o /home/root/server_log.log -e err.log /home/root/server.js
;;
stop)
echo "Stopping express server"
/home/root/node_modules/forever/bin/forever stop 0
;;
*)
echo "Usage: /etc/init.d/express-server {start|stop}"
exit 1
;;
esac
exit 0
# update to allow executable
chmod +x /etc/init.d/express-server.sh