-
Notifications
You must be signed in to change notification settings - Fork 17
Install Nodel as an init.d (Raspberry Pi) process
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 (comes with new Raspbian builds)
java -version
If you do not see the Java version number, install Java.
sudo apt-get update && sudo apt-get install oracle-java7-jdk
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 -home /usr/lib/jvm/jdk-7-oracle-armhf -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/jdk-7-oracle-armhf"
CLASS_PATH="/opt/nodel/nodel.jar:/usr/share/java/commons-daemon.jar"
CLASS=org.nodel.nodelhost.Service
USER=root
PID="/var/run/nodel.pid"
do_exec() {
$EXEC -home $JAVA_HOME -cp $CLASS_PATH -pidfile $PID $CLASS
}
do_stop() {
$EXEC -stop -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 the Pi and Nodel should start automatically
sudo shutdown -r now
Nodel: http://nodel.io/ | White Paper