Skip to content

Install Nodel on systemd (Arch Linux)

BlueJayLouche edited this page Sep 10, 2015 · 1 revision

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

Update and Upgrade the system

sudo pacman -Syyu

Reboot

sudo shutdown -r now

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 pacman -S java-jsvc

Test for installation of Java

java -version

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

sudo pacman -S jdk8-openjdk

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-openjdk -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/systemd/system/nodel.service 

Copy and paste the following code into the editor

[Unit]
Description=Nodel 

[Service]
Type=oneshot
ExecStart=/usr/bin/nodel start
ExecStop=/usr/bin/nodel stop
ExecRestart=/usr/bin/nodel restart
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
After=network-online.target

Create executable script for the service

sudo nano /usr/bin/nodel

Copy and paste the following code into the editor

#!/bin/sh
#change to working directory
cd /opt/nodel

# Setup variables
EXEC="/usr/bin/jsvc"
JAVA_HOME="/usr/lib/jvm/java-8-openjdk"
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 /usr/bin/nodel

Add to startup

sudo systemctl enable nodel.service

Reboot and Nodel should start automatically

sudo shutdown -r now