diff --git a/cds/etc/init.d/cds b/cds/etc/init.d/cds new file mode 100644 index 0000000..5facbab --- /dev/null +++ b/cds/etc/init.d/cds @@ -0,0 +1,69 @@ +#! /bin/sh +# +# /etc/init.d/cds -- startup script for OpenEMRConnect Central Document Store +# +### BEGIN INIT INFO +# Provides: cds +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Should-Start: $named +# Should-Stop: $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start CDS +# Description: Start the OpenEMRConnect Central Document Store +### END INIT INFO + + +NAME=cds + +CONFIGDIR="/etc/OpenEMRConnect/$NAME/" +PIDFILE="/var/run/$NAME.pid" +RUNTIMEDIR="/var/run/$NAME/" +LOGDIR="/var/log/$NAME" +LOGFILE="$LOGDIR/$NAME.log" +UBERJAR="/opt/OpenEMRConnect/$NAME/$NAME-1.0-SNAPSHOT-jar-with-dependencies.jar" +USER=oecuser +DAEMON="/usr/bin/java" +DAEMON_ARGS="-DconfigDirectory=$CONFIGDIR -DruntimeDirectory=$RUNTIMEDIR -jar $UBERJAR" + +if [ ! -d $RUNTIMEDIR ]; then + mkdir $RUNTIMEDIR; + chown $USER $RUNTIMEDIR; +fi + +if [ ! -d $LOGDIR ]; then + mkdir $LOGDIR; + chown $USER $LOGDIR; +fi + +case "$1" in +start) + echo -n "Starting daemon: "$NAME + start-stop-daemon --start --pidfile "$PIDFILE" --chuid $USER --verbose --make-pidfile --exec "$DAEMON" -- $DAEMON_ARGS >>$LOGFILE 2>&1 & + echo "." + ;; + +stop) + echo -n "Stopping daemon: "$NAME + start-stop-daemon --stop --pidfile "$PIDFILE" --retry=TERM/30/KILL/5 + echo "." + ;; + +status) + if kill -0 `cat $PIDFILE` > /dev/null 2>&1; then + echo "Running" + exit 0 + else + echo "Not running" + exit 1 + fi +;; + +*) + echo "Usage: "$1" {start|stop|status}" + exit 1 + +esac + +exit 0 diff --git a/esb/etc/init.d/esb b/esb/etc/init.d/esb new file mode 100644 index 0000000..17f1390 --- /dev/null +++ b/esb/etc/init.d/esb @@ -0,0 +1,69 @@ +#! /bin/sh +# +# /etc/init.d/esb -- startup script for OpenEMRConnect Enterprise Service Bus +# +### BEGIN INIT INFO +# Provides: esb +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Should-Start: $named +# Should-Stop: $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start ESB +# Description: Start the OpenEMRConnect Enterprise Service Bus +### END INIT INFO + + +NAME=esb + +CONFIGDIR="/etc/OpenEMRConnect/$NAME/" +PIDFILE="/var/run/$NAME.pid" +RUNTIMEDIR="/var/run/$NAME/" +LOGDIR="/var/log/$NAME" +LOGFILE="$LOGDIR/$NAME.log" +UBERJAR="/opt/OpenEMRConnect/$NAME/$NAME-1.0-SNAPSHOT-jar-with-dependencies.jar" +USER=oecuser +DAEMON="/usr/bin/java" +DAEMON_ARGS="-DconfigDirectory=$CONFIGDIR -DruntimeDirectory=$RUNTIMEDIR -jar $UBERJAR" + +if [ ! -d $RUNTIMEDIR ]; then + mkdir $RUNTIMEDIR; + chown $USER $RUNTIMEDIR; +fi + +if [ ! -d $LOGDIR ]; then + mkdir $LOGDIR; + chown $USER $LOGDIR; +fi + +case "$1" in +start) + echo -n "Starting daemon: "$NAME + start-stop-daemon --start --pidfile "$PIDFILE" --chuid $USER --verbose --make-pidfile --exec "$DAEMON" -- $DAEMON_ARGS >>$LOGFILE 2>&1 & + echo "." + ;; + +stop) + echo -n "Stopping daemon: "$NAME + start-stop-daemon --stop --pidfile "$PIDFILE" --retry=TERM/30/KILL/5 + echo "." + ;; + +status) + if kill -0 `cat $PIDFILE` > /dev/null 2>&1; then + echo "$NAME Running" + exit 0 + else + echo "$NAME Not running" + exit 1 + fi +;; + +*) + echo "Usage: "$1" {start|stop|status}" + exit 1 + +esac + +exit 0 diff --git a/esb/etc/init.d/fsb b/esb/etc/init.d/fsb new file mode 100644 index 0000000..b1c7bad --- /dev/null +++ b/esb/etc/init.d/fsb @@ -0,0 +1,70 @@ +#! /bin/sh +# +# /etc/init.d/fsb -- startup script for OpenEMRConnect Facilities Service Bus +# +### BEGIN INIT INFO +# Provides: fsb +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Should-Start: $named +# Should-Stop: $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start FSB +# Description: Start the OpenEMRConnect Facilities Service Bus +### END INIT INFO + + +NAME=fsb +PACKAGE=esb + +CONFIGDIR="/etc/OpenEMRConnect/$NAME/" +PIDFILE="/var/run/$NAME.pid" +RUNTIMEDIR="/var/run/$NAME/" +LOGDIR="/var/log/$NAME" +LOGFILE="$LOGDIR/$NAME.log" +UBERJAR="/opt/OpenEMRConnect/$NAME/$PACKAGE-1.0-SNAPSHOT-jar-with-dependencies.jar" +USER=oecuser +DAEMON="/usr/bin/java" +DAEMON_ARGS="-DconfigDirectory=$CONFIGDIR -DruntimeDirectory=$RUNTIMEDIR -jar $UBERJAR" + +if [ ! -d $RUNTIMEDIR ]; then + mkdir $RUNTIMEDIR; + chown $USER $RUNTIMEDIR; +fi + +if [ ! -d $LOGDIR ]; then + mkdir $LOGDIR; + chown $USER $LOGDIR; +fi + +case "$1" in +start) + echo -n "Starting daemon: "$NAME + start-stop-daemon --start --pidfile "$PIDFILE" --chuid $USER --verbose --make-pidfile --exec "$DAEMON" -- $DAEMON_ARGS >>$LOGFILE 2>&1 & + echo "." + ;; + +stop) + echo -n "Stopping daemon: "$NAME + start-stop-daemon --stop --pidfile "$PIDFILE" --retry=TERM/30/KILL/5 + echo "." + ;; + +status) + if kill -0 `cat $PIDFILE` > /dev/null 2>&1; then + echo "$NAME Running" + exit 0 + else + echo "$NAME Not running" + exit 1 + fi +;; + +*) + echo "Usage: "$1" {start|stop|status}" + exit 1 + +esac + +exit 0 diff --git a/loggingserver/etc/init.d/loggingserver b/loggingserver/etc/init.d/loggingserver new file mode 100644 index 0000000..261bf45 --- /dev/null +++ b/loggingserver/etc/init.d/loggingserver @@ -0,0 +1,69 @@ +#! /bin/sh +# +# /etc/init.d/loggingserver -- startup script for OpenEMRConnect Logging Server +# +### BEGIN INIT INFO +# Provides: loggingserver +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Should-Start: $named +# Should-Stop: $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start LOGGINGSERVER +# Description: Start the OpenEMRConnect Logging Server +### END INIT INFO + + +NAME=loggingserver + +CONFIGDIR="/etc/OpenEMRConnect/$NAME/" +PIDFILE="/var/run/$NAME.pid" +RUNTIMEDIR="/var/run/$NAME/" +LOGDIR="/var/log/$NAME" +LOGFILE="$LOGDIR/$NAME.log" +UBERJAR="/opt/OpenEMRConnect/$NAME/$NAME-1.0-SNAPSHOT-jar-with-dependencies.jar" +USER=oecuser +DAEMON="/usr/bin/java" +DAEMON_ARGS="-DconfigDirectory=$CONFIGDIR -DruntimeDirectory=$RUNTIMEDIR -jar $UBERJAR" + +if [ ! -d $RUNTIMEDIR ]; then + mkdir $RUNTIMEDIR; + chown $USER $RUNTIMEDIR; +fi + +if [ ! -d $LOGDIR ]; then + mkdir $LOGDIR; + chown $USER $LOGDIR; +fi + +case "$1" in +start) + echo -n "Starting daemon: "$NAME + start-stop-daemon --start --pidfile "$PIDFILE" --chuid $USER --verbose --make-pidfile --exec "$DAEMON" -- $DAEMON_ARGS >>$LOGFILE 2>&1 & + echo "." + ;; + +stop) + echo -n "Stopping daemon: "$NAME + start-stop-daemon --stop --pidfile "$PIDFILE" --retry=TERM/30/KILL/5 + echo "." + ;; + +status) + if kill -0 `cat $PIDFILE` > /dev/null 2>&1; then + echo "Running" + exit 0 + else + echo "Not running" + exit 1 + fi +;; + +*) + echo "Usage: "$1" {start|stop|status}" + exit 1 + +esac + +exit 0 diff --git a/mpi/etc/init.d/lpi b/mpi/etc/init.d/lpi new file mode 100644 index 0000000..ed6f778 --- /dev/null +++ b/mpi/etc/init.d/lpi @@ -0,0 +1,70 @@ +#! /bin/sh +# +# /etc/init.d/lpi -- startup script for OpenEMRConnect Local Patient Index +# +### BEGIN INIT INFO +# Provides: lpi +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Should-Start: $named +# Should-Stop: $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start LPI +# Description: Start the OpenEMRConnect Local Patient Index +### END INIT INFO + + +NAME=lpi +PACKAGE=mpi + +CONFIGDIR="/etc/OpenEMRConnect/$NAME/" +PIDFILE="/var/run/$NAME.pid" +RUNTIMEDIR="/var/run/$NAME/" +LOGDIR="/var/log/$NAME" +LOGFILE="$LOGDIR/$NAME.log" +UBERJAR="/opt/OpenEMRConnect/$NAME/$PACKAGE-1.0-SNAPSHOT-jar-with-dependencies.jar" +USER=oecuser +DAEMON="/usr/bin/java" +DAEMON_ARGS="-DconfigDirectory=$CONFIGDIR -DruntimeDirectory=$RUNTIMEDIR -jar $UBERJAR" + +if [ ! -d $RUNTIMEDIR ]; then + mkdir $RUNTIMEDIR; + chown $USER $RUNTIMEDIR; +fi + +if [ ! -d $LOGDIR ]; then + mkdir $LOGDIR; + chown $USER $LOGDIR; +fi + +case "$1" in +start) + echo -n "Starting daemon: "$NAME + start-stop-daemon --start --pidfile "$PIDFILE" --chuid $USER --verbose --make-pidfile --exec "$DAEMON" -- $DAEMON_ARGS >>$LOGFILE 2>&1 & + echo "." + ;; + +stop) + echo -n "Stopping daemon: "$NAME + start-stop-daemon --stop --pidfile "$PIDFILE" --retry=TERM/30/KILL/5 + echo "." + ;; + +status) + if kill -0 `cat $PIDFILE` > /dev/null 2>&1; then + echo "$NAME Running" + exit 0 + else + echo "$NAME Not running" + exit 1 + fi +;; + +*) + echo "Usage: "$1" {start|stop|status}" + exit 1 + +esac + +exit 0 diff --git a/mpi/etc/init.d/mpi b/mpi/etc/init.d/mpi new file mode 100644 index 0000000..aac19b2 --- /dev/null +++ b/mpi/etc/init.d/mpi @@ -0,0 +1,69 @@ +#! /bin/sh +# +# /etc/init.d/mpi -- startup script for OpenEMRConnect Master Patient Index +# +### BEGIN INIT INFO +# Provides: mpi +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Should-Start: $named +# Should-Stop: $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start MPI +# Description: Start the OpenEMRConnect Master Patient Index +### END INIT INFO + + +NAME=mpi + +CONFIGDIR="/etc/OpenEMRConnect/$NAME/" +PIDFILE="/var/run/$NAME.pid" +RUNTIMEDIR="/var/run/$NAME/" +LOGDIR="/var/log/$NAME" +LOGFILE="$LOGDIR/$NAME.log" +UBERJAR="/opt/OpenEMRConnect/$NAME/$NAME-1.0-SNAPSHOT-jar-with-dependencies.jar" +USER=oecuser +DAEMON="/usr/bin/java" +DAEMON_ARGS="-DconfigDirectory=$CONFIGDIR -DruntimeDirectory=$RUNTIMEDIR -jar $UBERJAR" + +if [ ! -d $RUNTIMEDIR ]; then + mkdir $RUNTIMEDIR; + chown $USER $RUNTIMEDIR; +fi + +if [ ! -d $LOGDIR ]; then + mkdir $LOGDIR; + chown $USER $LOGDIR; +fi + +case "$1" in +start) + echo -n "Starting daemon: "$NAME + start-stop-daemon --start --pidfile "$PIDFILE" --chuid $USER --verbose --make-pidfile --exec "$DAEMON" -- $DAEMON_ARGS >>$LOGFILE 2>&1 & + echo "." + ;; + +stop) + echo -n "Stopping daemon: "$NAME + start-stop-daemon --stop --pidfile "$PIDFILE" --retry=TERM/30/KILL/5 + echo "." + ;; + +status) + if kill -0 `cat $PIDFILE` > /dev/null 2>&1; then + echo "$NAME Running" + exit 0 + else + echo "$NAME Not running" + exit 1 + fi +;; + +*) + echo "Usage: "$1" {start|stop|status}" + exit 1 + +esac + +exit 0 diff --git a/oeclib/src/main/java/ke/go/moh/oec/lib/Mediator.java b/oeclib/src/main/java/ke/go/moh/oec/lib/Mediator.java index 687556f..f98875f 100644 --- a/oeclib/src/main/java/ke/go/moh/oec/lib/Mediator.java +++ b/oeclib/src/main/java/ke/go/moh/oec/lib/Mediator.java @@ -204,7 +204,10 @@ public Mediator() { */ static void setRuntimeDirectory() { try { - runtimeDirectory = ""; + runtimeDirectory = System.getProperty("runtimeDirectory"); + if (runtimeDirectory == null) { + runtimeDirectory = ""; + } for (int i = 2;; i++) { // Try current directory, then "runtime2/", "runtime3/", etc. RandomAccessFile raf = new RandomAccessFile(runtimeDirectory + "lockfile.lck", "rw"); FileChannel fc = raf.getChannel(); @@ -218,8 +221,11 @@ static void setRuntimeDirectory() { Logger.getLogger(Mediator.class.getName()).log(Level.SEVERE, "Can''t lock directory {0}. please either create the directory or run the app fewer times.", runtimeDirectory); + Logger.getLogger(Mediator.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage()); System.exit(1); } + Logger.getLogger(Mediator.class.getName()).log(Level.INFO, + "Using runtimeDirectory {0}", runtimeDirectory); } static public String getRuntimeDirectory() { @@ -322,15 +328,25 @@ public static Logger getLogger(String loggerName) { public static Properties getProperties() { if (properties == null) { properties = new Properties(); + + // If a system property defining the configuration directory is + // available, use it. + String configDirectory = System.getProperty("configDirectory"); + if (configDirectory == null) { + configDirectory = runtimeDirectory; + } + // First attempt to load from the filesystem, which will only work // in a dev environment (i.e. from within the IDE), and for many, // only for runtime2 or better. + // On deployments, the properties file should live in the jar, and - // thus require loading as a resource. + // thus require loading as a resource (unless the system property + // for "configDirectory" is supplied). String propFileName = "/openemrconnect.properties"; try { - String propPathName = runtimeDirectory + propFileName; + String propPathName = configDirectory + propFileName; Logger.getLogger(Mediator.class.getName()).log(Level.INFO, "Attempt property load from file ''{0}''", propPathName);