aboutsummaryrefslogtreecommitdiffstats
path: root/bin/srt
diff options
context:
space:
mode:
Diffstat (limited to 'bin/srt')
-rwxr-xr-xbin/srt41
1 files changed, 30 insertions, 11 deletions
diff --git a/bin/srt b/bin/srt
index 06940ee8..7af2491f 100755
--- a/bin/srt
+++ b/bin/srt
@@ -45,17 +45,34 @@ databaseCheck()
return $retval
}
+get_srt_env_settings() {
+ mainapp="yp"
+ # Apply all shell settings except default app 'yp'
+ # Only look in directories with proper 'datasource.json' files
+ for envscript in $(find ./bin -name "datasource.json") ; do
+ envscript=${envscript/datasource.json/srtool_env.sh}
+ if [ -f "$envscript" -a "$envscript" = "${envscript/bin\/yp/}" ] ; then
+ . $envscript
+ fi
+ done
+ # if no main app, default to 'yp'
+ if [ -z "$SRT_MAIN_APP" ] ; then
+ . ./bin/yp/srtool_env.sh
+ fi
+ echo "SRT_MAIN_APP=$SRT_MAIN_APP"
+}
+
webserverKillAll()
{
local pidfile
for pidfile in ${SRT_BASE_DIR}/.srtmain.pid ; do
if [ -f ${pidfile} ] ; then
pid=`cat ${pidfile}`
- while kill -0 $pid 2>/dev/null; do
- echo "KILL:$pid"
- kill -SIGTERM -9 $pid 2>/dev/null
- sleep 1
- done
+ while kill -0 $pid 2>/dev/null; do
+ echo "KILL:$pid"
+ kill -SIGTERM -9 $pid 2>/dev/null
+ sleep 1
+ done
rm ${pidfile}
fi
done
@@ -157,6 +174,9 @@ SRT_BASE_DIR=$(readlink -f $SRT_BASE_DIR)
SRT_BASE_DIR=$(dirname $SRT_BASE_DIR)
MANAGE="python3 $SRT_BASE_DIR/lib/manage.py"
+# Fetch the datasource environent settings
+get_srt_env_settings
+
# insure basic directories are present
mkdir -p $SRT_BASE_DIR/data
mkdir -p $SRT_BASE_DIR/data/cache
@@ -193,7 +213,7 @@ for param in $*; do
;;
*)
if [ "manage" == "$CMD" ] ; then
- cd $SRT_BASE_DIR/lib
+ cd $SRT_BASE_DIR/lib
manage_cmd="$manage_cmd $param"
else
echo "$HELP"
@@ -206,7 +226,6 @@ done
verify_prereq || exit 1
-
# this defines the dir SRTool will use for
# 1) the sqlite db if that is being used.
# 2) pid's we need to clean up on exit/shutdown
@@ -214,9 +233,9 @@ verify_prereq || exit 1
# Determine the action. If specified by arguments, fine, if not, toggle it
if [ "$CMD" = "start" ] ; then
if [ -n "$BBSERVER" ]; then
- echo " SRT is already running. Exiting..."
- exit 1
-fi
+ echo " SRT is already running. Exiting..."
+ exit 1
+ fi
elif [ "$CMD" = "" ]; then
echo "No command specified"
echo "$HELP"
@@ -230,7 +249,7 @@ case $CMD in
start )
# check if addr:port is not in use
if [ "$CMD" == 'start' ] ; then
- $MANAGE checksocket "$ADDR_PORT" || exit 1
+ $MANAGE checksocket "$ADDR_PORT" || exit 1
fi
if ! webserverStartAll; then