Skip to content

Install Nodel as an init.d (Ubuntu pre 15.04) Process

scroix edited this page Nov 22, 2016 · 1 revision

The latest Nodel JAR contains entry-points to allow use with JSVC.

Copy Nodel files into place. Replace with your nodel version.

sudo mkdir /opt/nodel
sudo cp nodelHost-<nodelversion>.jar /opt/nodel/nodel.jar

Install JSVC

sudo apt-get install jsvc

Test for installation of Java

java -version

If you do not see the Java version number, install Java.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Repeat the test above to verify installation.

Run on the console (for testing):

cd /opt/nodel
sudo java -cp nodel.jar org.nodel.jyhost.Launch

After running this test, you should be able to view Nodel in a browser.

Run on the console using jsvc (for testing):

sudo /usr/bin/jsvc -cwd /opt/nodel -home /usr/lib/jvm/java-8-oracle -pidfile /var/run/jsvc.pid -cp /opt/nodel/nodel.jar:/usr/share/java/commons-daemon.jar org.nodel.nodelhost.Service

After running this test, you should be able to view Nodel in a browser.

If the computer is multi-homed (has two or more active network interfaces) then you will need to create a bootstrap.json file before proceeding. Check _example_bootstrap.json for details.

Create daemon startup script:

sudo nano /etc/init.d/nodel 

Copy and paste the following code into the editor

#!/bin/sh
### BEGIN INIT INFO
# Provides:          nodel
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: nodel
# Description:       nodel daemon
### END INIT INFO

#change to working directory
cd /opt/nodel

# Setup variables
EXEC="/usr/bin/jsvc"
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
CLASS_PATH="/opt/nodel/nodel.jar":"/usr/share/java/commons-daemon.jar"
CLASS=org.nodel.nodelhost.Service
USER=root
CWD="/opt/nodel"
PID="/var/run/nodel.pid"

do_exec() {
    $EXEC -cwd $CWD -home $JAVA_HOME -cp $CLASS_PATH -pidfile $PID $CLASS
}

do_stop() {
    $EXEC -stop -cwd $CWD -home $JAVA_HOME -cp $CLASS_PATH -pidfile $PID $CLASS
}

case "$1" in
    start)
        echo "Starting Nodel"
        do_exec
            ;;
    stop)
        echo "Stopping Nodel"
        do_stop
            ;;
    restart)
        if [ -f "$PID" ]; then
            echo "Restarting Nodel"
            do_stop
            do_exec
        else
            echo "service not running, will do nothing"
            exit 1
        fi
            ;;
    *)
            echo "usage: daemon {start|stop|restart}" >&2
            exit 3
            ;;
esac

Press ctrl-x to exit and save the file

Set execute permissions:

sudo chmod a+x /etc/init.d/nodel

Add to startup

sudo update-rc.d nodel defaults

Reboot and Nodel should start automatically

sudo shutdown -r now