Skip to content

Instantly share code, notes, and snippets.

@bbengfort
Last active December 18, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bbengfort/5850492 to your computer and use it in GitHub Desktop.
Save bbengfort/5850492 to your computer and use it in GitHub Desktop.
An init.d script for starting and stopping the WIMsService
#! /bin/sh
# Copyright (c) 2013 OpenWIMs.org
# All rights reserved
#
# Author: Benjamin Bengfort, 2013
#
# /etc/init.d/wimss
### BEGIN INIT INFO
# Provides: wimss
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: The WIMsService daemon, providing a real-time WIM analyzer
# Description: The wimss service is an always up realtime WIM analyzer.
# It runs on port 9250 and accepts sentences and returns JSON data.
### END INIT INFO
# Check for binaries
JAVA_BIN=/usr/bin/java
test -x $JAVA_BIN || { echo "$JAVA_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
WIMSS_BIN=/opt/wimss/WIMsService.jar
#test -x $WIMSS_BIN || { echo "$WIMSS_BIN not installed";
# if [ "$1" = "stop" ]; then exit 0;
# else exit 6; fi; }
# Check for config and read it
#WIMSS_CONFIG=/etc/wimss/wimss.cfg
#test -r $WIMSS_CONFIG || { echo "$WIMSS_CONFIG not existing";
# if [ "$1" = "stop" ]; then exit 0;
# else exit 7; fi; }
#
#. $WIMSS_CONFIG
# Load the rc.status script for WIMsService
#. /etc/rc.status
# Reset status for WIMsService
#rc_reset
case "$1" in
start)
echo -n "Starting the WIMsService"
$JAVA_BIN -Xmx3g -classpath "$WIMSS_BIN:lib/*" org.openwims.WIMsService.WIMsService port=9250 start
# rc_status -v
;;
stop)
echo -n "Stopping the WIMsService"
$JAVA_BIN -classpath "$WIMSS_BIN" org.openwims.WIMsService.WIMsService port=9250 stop
# rc_status -v
;;
test)
echo -n "Testing the WIMsService"
$JAVA_BIN -classpath "$WIMSS_BIN" org.openwims.WIMsService.WIMsClient port=9250
# rc_status -v
;;
restart)
echo -n "Restarting the WIMsService"
$JAVA_BIN -classpath "$WIMSS_BIN" org.openwims.WIMsService.WIMsService port=9250 stop
$JAVA_BIN -Xmx3g -classpath "$WIMSS_BIN:lib/*" org.openwims.WIMsService.WIMsService port=9250 start
;;
*)
echo "Usage: $0 {start|stop|test|restart}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment