Skip to content

Install Nodel as a serviced (Ubuntu post 15.04) process

mcartmel edited this page Apr 20, 2017 · 22 revisions

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, or the Java version is not 8 (1.8), install Java.

sudo apt-get install openjdk-8-jre-headless

Repeat the test above to verify installation.

Run on the console (for testing):

cd /opt/nodel
sudo java -jar nodel.jar

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-1.8.0-openjdk-amd64 -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. NOTE: fixed in new releases.

Create daemon startup script:

sudo nano /lib/systemd/system/nodel.service 

Copy and paste the following code into the editor. You may want to modify the 'user' parameter to run Nodel as a different user ('nodel' by default).

Create service as user

[Unit]
Description=Nodel
After=network-online.target

[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
RestartSec=30
Restart=on-failure
ExecStart=/usr/bin/jsvc \
            -cp /usr/share/java/commons-daemon.jar:/opt/nodel/nodel.jar \
            -cwd /opt/nodel \
            -user nodel \
            -java-home ${JAVA_HOME} \
            -pidfile /var/run/nodel/nodel.pid \
            -errfile SYSLOG \
            -outfile SYSLOG \
            org.nodel.nodelhost.Service

ExecStop=/usr/bin/jsvc \
            -pidfile /var/run/nodel.pid \
            -stop \
            org.nodel.nodelhost.Service

[Install]
WantedBy=multi-user.target

Press ctrl-x to exit and save the file

Create new directory for .pid

sudo mkdir /var/run/nodel

Set user permissions for new directory

sudo chown -R nodel.nodel /var/run/nodel

Set user permissions for Nodel directory

sudo chown -R nodel.nodel /opt/nodel

Add to startup

sudo systemctl enable nodel.service

Reboot and Nodel should start automatically

sudo shutdown -r now