当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Node fails to run on bootup script

问题描述:

I have a simple init.d script that runs a bash script:

#! /bin/sh

### BEGIN INIT INFO

# Provides: registertool

# Required-Start: $network $local_fs $syslog $remote_fs networking

# Required-Stop: $network $local_fs $syslog $remote_fs

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: Starts registration script

# Description: Starts the registration script

### END INIT INFO

do_start() {

cd $APP_DIR

./register.sh -v &

echo $! > "$PID_FILE"

log_action_msg "Registration started with pid $!"

}

case $1 in

start)

do_start

;;

stop)

log_end_msg 0

;;

restart|force-reload)

log_end_msg 0

;;

*)

echo $USAGE >&2

exit 1

;;

esac

Inside the script, I define my node as NODE=$(which node) and run an application as $NODE myApp.js. I have defined the path in the script as

PATH="$PATH:/usr/local/bin:/usr/sbin:/sbin:/usr/bin/:/bin"

However, my node is not even called! What am I doing wrong? What else do I need to wait for to boot up?

网友答案:

NODE=$(which node) will search $PATH to find the executable. If your path has not been defined, it won't find anything. Try having your script log each step so you can see where it goes sideways.

./register.sh will depend on the current directory being something specific. During system startup, cwd may not even be defined.

分享给朋友:
您可能感兴趣的文章:
随机阅读: