gpt4 book ai didi

node.js - rc.local 脚本手动运行但启动失败...是什么原因?

转载 作者:太空宇宙 更新时间:2023-11-04 02:32:44 26 4
gpt4 key购买 nike

我可以手动运行我的/etc/rc.local 文件,它在启动时运行(将字符串回显到文件),但由于某种原因,forever(npm 包)失败了。我正在 EC2 实例上运行 Amazon Linux AMI(如果有帮助的话)。

我可以在哪里了解它失败的原因,或者你能告诉我我做错了什么吗?

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

echo "rc.local is running..." > /tmp/rc.local-output

touch /var/lock/subsys/local

exec /usr/local/bin/forever start -c /usr/local/bin/node /var/www/node/myapp/app.js &
exec /usr/local/bin/forever start -c /usr/local/bin/node /var/www/node/myapp/tools/push/push_service.js &

好吧,事情似乎变得更好了,我将 rc.local 文件更新为:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

exec 2> /tmp/rc.local.log # send stderr from rc.local to a log file
exec 1>&2 # send stdout to the same log file
set -x # tell sh to display commands before execution

echo "rc.local is running..." >> /tmp/rc.local-output

touch /var/lock/subsys/local

/usr/local/bin/forever start /var/www/node/myapp/app.js &
/usr/local/bin/forever start /var/www/node/myapp/tools/push/push_service.js &

/tmp/rc.local.log 告诉我这一点:

/usr/bin/env: Node :没有这样的文件或目录

最佳答案

我想您仍然设置了执行位?

ls -l /etc/rc.local

-rwxr-xr-x 1 root root 306 Dec 26 2010 /etc/rc.local

此外,脚本或工具 /usr/local/bin/forever 也必须是可执行的(适当设置“x”位),但您在手动测试时会检测到。

我可以想象这在启动时不起作用的唯一原因是它所需的东西那时尚未准备好,因此永久工具的启动失败。永远是一个剧本吗?如果是的话,也许你可以告诉我们里面有什么?

关于node.js - rc.local 脚本手动运行但启动失败...是什么原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25130398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com