diff options
author | startxfr <clarue@startx.fr> | 2016-02-06 05:05:57 +0100 |
---|---|---|
committer | startxfr <clarue@startx.fr> | 2016-02-06 05:05:57 +0100 |
commit | 5cff390c081bdfb756a8977ad0bd56d778202d6b (patch) | |
tree | ce018b9be9ad054e4f7aa6891d7b4668c1ad74af /Services/postgres/run.sh | |
parent | 0f3bcf30ae748a75c22a03d4655dba4d8dc71185 (diff) | |
download | phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.gz phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.bz2 phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.tar.xz phpmyadmin-5cff390c081bdfb756a8977ad0bd56d778202d6b.zip |
reorg avec gestion des sig
Diffstat (limited to 'Services/postgres/run.sh')
-rw-r--r-- | Services/postgres/run.sh | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/Services/postgres/run.sh b/Services/postgres/run.sh index 1c5436d..baea45c 100644 --- a/Services/postgres/run.sh +++ b/Services/postgres/run.sh @@ -13,11 +13,11 @@ set_listen_addresses() { function check_postgresql_environment { check_environment if [ ! -v DATA_PATH ]; then - DATA_PATH="/data/postgresql" + DATA_PATH="/data" export DATA_PATH fi if [ ! -v LOG_PATH ]; then - LOG_PATH="/data/logs/postgresql" + LOG_PATH="/logs" export LOG_PATH fi } @@ -92,6 +92,12 @@ function begin_config { echo "Installing PostgreSQL in $DATA_PATH is DONE !" chown root:postgres $STARTUPLOG chmod ug+w $STARTUPLOG + config_startserver + config_createadmin + config_createuser + config_createdatabase + config_importsql + config_stopserver fi } @@ -203,29 +209,33 @@ function end_config { echo "=> END POSTGRESQL CONFIGURATION" } +function stop_postgres_handler { + su - postgres -c "pg_ctl -D $DATA_PATH -m fast -w stop" + set_listen_addresses '*' + sleep 2 + echo "+=====================================================" | tee -a $STARTUPLOG + echo "| Container $HOSTNAME is now STOPPED" | tee -a $STARTUPLOG + echo "+=====================================================" | tee -a $STARTUPLOG + exit 143; # 128 + 15 -- SIGTERM +} + # Start the postgresql server as a deamon and execute it inside # the running shell -function start_daemon { - echo "=> Starting postgresql daemon ..." | tee -a $STARTUPLOG - display_container_started | tee -a $STARTUPLOG - su - postgres -c "pg_ctl -D $DATA_PATH -w start " - echo "postgres daemon is started" > /tmp/started - exec tail -f /tmp/started +function start_service_postgres { + trap 'kill ${!}; stop_postgres_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 - postgres -c "pg_ctl -D $DATA_PATH -w start " & + while true + do + tail -f /dev/null & wait ${!} + done } -if [[ "$0" == *"run.sh" && ! $1 = "" ]];then - eval "$@"; -fi - check_postgresql_environment | tee -a $STARTUPLOG display_container_postgresql_header | tee -a $STARTUPLOG begin_config | tee -a $STARTUPLOG -config_startserver | tee -a $STARTUPLOG -config_createadmin | tee -a $STARTUPLOG -config_createuser | tee -a $STARTUPLOG -config_createdatabase | tee -a $STARTUPLOG -config_importsql | tee -a $STARTUPLOG -config_stopserver | tee -a $STARTUPLOG end_config | tee -a $STARTUPLOG -start_daemon +start_service_postgres |