summaryrefslogtreecommitdiffstats
path: root/Services/mongo/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Services/mongo/run.sh')
-rw-r--r--Services/mongo/run.sh34
1 files changed, 22 insertions, 12 deletions
diff --git a/Services/mongo/run.sh b/Services/mongo/run.sh
index 14e00db..e3356c9 100644
--- a/Services/mongo/run.sh
+++ b/Services/mongo/run.sh
@@ -4,11 +4,11 @@ source /bin/sx-lib.sh
function check_mongodb_environment {
check_environment
if [ ! -v APP_PATH ]; then
- APP_PATH="/data/mongodb"
+ APP_PATH="/data"
export APP_PATH
fi
if [ ! -v LOG_PATH ]; then
- LOG_PATH="/data/logs/mongodb"
+ LOG_PATH="/logs"
export LOG_PATH
fi
}
@@ -69,23 +69,33 @@ function end_config {
echo "=> END MONGODB CONFIGURATION"
}
+function stop_mongo_handler {
+ killall mongod
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ echo "| Container $HOSTNAME is now STOPPED" | tee -a $STARTUPLOG
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ exit 143; # 128 + 15 -- SIGTERM
+}
+
+
# Start the mongodb server as a deamon and execute it inside
# the running shell
-function start_daemon {
- echo "=> Starting mongodb daemon ..." | tee -a $STARTUPLOG
+function start_service_mongo {
+ trap 'kill ${!}; stop_mongo_handler' SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL SIGSTOP SIGCONT
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ echo "| Container $HOSTNAME is now RUNNING" | tee -a $STARTUPLOG
+ echo "+=====================================================" | tee -a $STARTUPLOG
su mongodb
- display_container_started | tee -a $STARTUPLOG
/usr/bin/mongod --logappend --logpath $LOG_PATH/mongodb.log --dbpath $DATA_PATH --journal --fork
- exec tail -f $LOG_PATH/mongodb.log
+ exec tail -f /dev/null &
+ while true
+ do
+ tail -f /dev/null & wait ${!}
+ done
}
-
-if [[ "$0" == *"run.sh" && ! $1 = "" ]];then
- eval "$@";
-fi
-
check_mongodb_environment | tee -a $STARTUPLOG
display_container_mongodb_header | tee -a $STARTUPLOG
begin_config | tee -a $STARTUPLOG
end_config | tee -a $STARTUPLOG
-start_daemon
+start_service_mongo