summaryrefslogtreecommitdiffstats
path: root/Services/mongo
diff options
context:
space:
mode:
authorstartxfr <clarue@startx.fr>2016-02-06 05:05:57 +0100
committerstartxfr <clarue@startx.fr>2016-02-06 05:05:57 +0100
commit5cff390c081bdfb756a8977ad0bd56d778202d6b (patch)
treece018b9be9ad054e4f7aa6891d7b4668c1ad74af /Services/mongo
parent0f3bcf30ae748a75c22a03d4655dba4d8dc71185 (diff)
downloadphpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.gz
phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.bz2
phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.xz
phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.zip
reorg avec gestion des sig
Diffstat (limited to 'Services/mongo')
-rw-r--r--Services/mongo/Dockerfile6
-rw-r--r--Services/mongo/README.md16
-rw-r--r--Services/mongo/docker-compose.yml4
-rw-r--r--Services/mongo/run.sh34
4 files changed, 35 insertions, 25 deletions
diff --git a/Services/mongo/Dockerfile b/Services/mongo/Dockerfile
index 98ec5f8..c3f1bab 100644
--- a/Services/mongo/Dockerfile
+++ b/Services/mongo/Dockerfile
@@ -4,9 +4,9 @@ MAINTAINER Christophe LARUE <dev@startx.fr>
USER root
RUN dnf -y install mongodb mongodb-server libmongo-client rsyslog-mongodb && \
dnf clean all
-ENV STARTUPLOG=/data/logs/mongodb/startup.log \
- LOG_PATH=/data/logs/mongodb \
- DATA_PATH=/data/mongodb
+ENV STARTUPLOG=/logs/startup.log \
+ LOG_PATH=/logs \
+ DATA_PATH=/data
COPY *.sh /bin/
RUN chmod 775 /bin/run.sh && \
mkdir -p $DATA_PATH && \
diff --git a/Services/mongo/README.md b/Services/mongo/README.md
index 5951629..194c2e7 100644
--- a/Services/mongo/README.md
+++ b/Services/mongo/README.md
@@ -29,8 +29,8 @@ service:
CONTAINER_SERVICE: "mongo"
CONTAINER_INSTANCE: "service-mongo"
volumes:
- - "/tmp/container/logs/mongo:/data/logs/mongo"
- - "/tmp/container/mongo:/data/mongo"
+ - "/tmp/container/logs/mongo:/logs"
+ - "/tmp/container/mongo:/data"
```
## Docker-compose in various situations
@@ -88,8 +88,8 @@ CMD ["/bin/run.sh"]
| CONTAINER_TYPE | `string` | `no` | Container family (os, service, application. could be enhanced
| CONTAINER_SERVICE | `string` | `no` | Define the type of service or application provided
| HOSTNAME | `auto` | `auto` | Container unique id automatically assigned by docker daemon at startup
-| LOG_PATH | `auto` | `auto` | default set to /data/logs/mongo and used as a volume mountpoint
-| DATA_PATH | `auto` | `auto` | default set to /data/mongo and used as a volume mountpoint
+| LOG_PATH | `auto` | `auto` | default set to /logs and used as a volume mountpoint
+| DATA_PATH | `auto` | `auto` | default set to /data and used as a volume mountpoint
## Exposed port
@@ -101,8 +101,8 @@ CMD ["/bin/run.sh"]
| Container directory | Description |
|----------------------|--------------------------------------------------------------------------|
-| /data/logs/mongo | log directory used to record container and mongo logs
-| /data/mongo | data directory served by mongo. If empty will be filled with app on startup. In other case use content from mountpoint or data volumes
+| /logs | log directory used to record container and mongo logs
+| /data | data directory served by mongo. If empty will be filled with app on startup. In other case use content from mountpoint or data volumes
## Testing the service
@@ -123,8 +123,8 @@ You must have a working environment with the source code of this repository. Rea
1. Jump into the container directory with `cd Services/mongo`
2. Build the container using `docker build -t sv-mongo .`
3. Run this container
- 1. Interactively with `docker run -p 27017:27017 -v /data/logs/mongo -it sv-mongo`. If you add a second parameter (like `/bin/bash`) to will run this command instead of the default entrypoint. Usefull to interact with this container (ex: `/bin/bash`, `/bin/ps -a`, `/bin/df -h`,...)
- 2. As a daemon with `docker run -p 27017:27017 -v /data/logs/mongo -d sv-mongo`
+ 1. Interactively with `docker run -p 27017:27017 -v /logs -it sv-mongo`. If you add a second parameter (like `/bin/bash`) to will run this command instead of the default entrypoint. Usefull to interact with this container (ex: `/bin/bash`, `/bin/ps -a`, `/bin/df -h`,...)
+ 2. As a daemon with `docker run -p 27017:27017 -v /logs -d sv-mongo`
### Build & run a container using `docker-compose`
diff --git a/Services/mongo/docker-compose.yml b/Services/mongo/docker-compose.yml
index 427771d..3109a53 100644
--- a/Services/mongo/docker-compose.yml
+++ b/Services/mongo/docker-compose.yml
@@ -13,5 +13,5 @@ server:
CONTAINER_SERVICE: "mongo"
CONTAINER_INSTANCE: "service-mongo"
volumes:
- - "/tmp/container/logs/mongodb:/data/logs/mongodb"
- - "/tmp/container/mongodb:/data/mongodb" \ No newline at end of file
+ - "/tmp/container/logs/mongodb:/logs"
+ - "/tmp/container/mongodb:/data" \ No newline at end of file
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