Domanda

I have been playing with the Intel Galileo for a while and have create a node.js and express server which i am running with forever. I'm now trying to get my command to fire when the machine boots up but I'm struggling. I have used the method below, let me know which logs etc ay be useful and I can provide them:

# 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
È stato utile?

Soluzione

You'll need to create a link from /etc/rcS.d to your startup script
$> cd /etc/rcS.d
$> ln -s /etc/init.d/express-server.sh SNNexpress-server.sh

Where NN is a number of your choice to determine when during the startup sequence you want your script to get called. If your script depends on networking, then it should be start after networking service was called.

Altri suggerimenti

You can also upload your Node.js code to your Galileo using Intel XDK IoT edition(https://software.intel.com/en-us/html5/xdk-iot), it will persist after rebooting.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top