Hi all.
Trying to get my b4j app to run at startup. I have read and re-read ideas on the forum and just cannot get this script to work. I can type at the command line and start the program fine.
If I use this script and check the log I get 'Error: Unable to access jarfile /home/cloud-kvs/CloudKvs_Server.jar'
Any ideas?
Trying to get my b4j app to run at startup. I have read and re-read ideas on the forum and just cannot get this script to work. I can type at the command line and start the program fine.
B4X:
nohup /home/jre1.8.0_91/bin/java -jar /home/cloud-kvs/CloudKvs_Server.jar > nohup.out &[]
If I use this script and check the log I get 'Error: Unable to access jarfile /home/cloud-kvs/CloudKvs_Server.jar'
Any ideas?
B4X:
#!/bin/sh
### BEGIN INIT INFO
# Provides: Cloud KVS Server
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Cloud KVS Server
# Description: Cloud KVS Server
### END INIT INFO
# Actions
SERVICE_NAME=CloudKvsServer
PATH_TO_JAR=/home/cloud-kvs/CloudKvs_Server.jar
PID_PATH_NAME=/tmp/cloudkvs-pid
case $1 in
start)
echo "Starting $SERVICE_NAME ..."
if [ ! -f $PID_PATH_NAME ]; then
#nohup /home/jre1.8.0_91/bin/java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null &
nohup /home/jre1.8.0_91/bin/java -jar $PATH_TO_JAR > nohup.out &
# Change Here the filename of the .log file
# if no Logfile is neded then comment the next line with #
# nohup /home/jre1.8.0_91/bin/java -jar $PATH_TO_JAR /tmp 2>> /var/log/gpio.log >> /var/log/gpio.log &
echo $! > $PID_PATH_NAME
echo "$SERVICE_NAME started ..."
else
echo "$SERVICE_NAME is already running ..."
fi
;;
stop)
if [ -f $PID_PATH_NAME ]; then
PID=$(cat $PID_PATH_NAME);
echo "$SERVICE_NAME stoping ..."
kill $PID;
echo "$SERVICE_NAME stopped ..."
rm $PID_PATH_NAME
else
echo "$SERVICE_NAME is not running ..."
fi
;;
restart)
if [ -f $PID_PATH_NAME ]; then
PID=$(cat $PID_PATH_NAME);
echo "$SERVICE_NAME stopping ...";
kill $PID;
echo "$SERVICE_NAME stopped ...";
rm $PID_PATH_NAME
echo "$SERVICE_NAME starting ..."
#nohup /home/jre1.8.0_91/bin/java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null &
nohup /home/jre1.8.0_91/bin/java -jar $PATH_TO_JAR > nohup.out &
echo $! > $PID_PATH_NAME
echo "$SERVICE_NAME started ..."
else
echo "$SERVICE_NAME is not running ..."
fi
;;
esac