From 8facd589911f81e1ac151d2cfa5bea597711054c Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sun, 25 Oct 2020 02:01:52 -0400 Subject: [PATCH] [ADD] docker add update_all_db and stop_before_init - stop_before_init wait before launch odoo script - update_all_db for an update of database - docker_build.sh add --no-cache option - Increate limit_time in odoo_conf --- docker-compose.yml | 3 +++ docker/entrypoint.sh | 19 +++++++++++++++++-- docker/odoo.conf | 4 ++-- script/docker_build.sh | 15 +++++++++++---- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 44203f5..cc2a6e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,9 @@ services: PASSWORD: mysecretpassword USER: odoo POSTGRES_DB: postgres + STOP_BEFORE_INIT: "False" + DB_NAME: "" + UPDATE_ALL_DB: "False" depends_on: - db command: odoo diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index bf1137f..3ed326c 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -71,14 +71,29 @@ case "$1" in exec odoo "$@" || exec odoo-bin "$@" else cd $ODOO_PREFIX + if [[ "${STOP_BEFORE_INIT}" == "True" ]] ; then + sleep 999999 + fi ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + if [[ "${UPDATE_ALL_DB}" == "True" ]] ; then + # --stop-after-init + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" + else + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + fi fi ;; -*) cd $ODOO_PREFIX + if [[ "${STOP_BEFORE_INIT}" == "True" ]] ; then + sleep 999999 + fi ./docker/wait-for-psql.py ${DB_ARGS[@]} --timeout=30 - exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + if [[ "${UPDATE_ALL_DB}" == "True" ]] ; then + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf -u all -d "${DB_NAME}" + else + exec ./.venv/bin/python $ODOO_EXEC_BIN "$@" "${DB_ARGS[@]}" -c /etc/odoo/odoo.conf + fi ;; *) exec "$@" diff --git a/docker/odoo.conf b/docker/odoo.conf index b9b9c4e..1a2c04e 100644 --- a/docker/odoo.conf +++ b/docker/odoo.conf @@ -446,13 +446,13 @@ max_cron_threads = 1 # Prevents the worker from using more than CPU seconds for each # request. If the limit is exceeded, the worker is killed #----------------------------------------------------------------------------- -limit_time_cpu = 600 +limit_time_cpu = 2400 #----------------------------------------------------------------------------- # Prevents the worker from taking longer than seconds to process a # request. If the limit is exceeded, the worker is killed. #----------------------------------------------------------------------------- -limit_time_real = 900 +limit_time_real = 3600 #----------------------------------------------------------------------------- # Maximum allowed virtual memory per worker. If the limit is exceeded, the diff --git a/script/docker_build.sh b/script/docker_build.sh index 3a99a79..4af24e2 100755 --- a/script/docker_build.sh +++ b/script/docker_build.sh @@ -1,15 +1,22 @@ #!/usr/bin/env bash . ./env_var.sh +ARGS="" + +for arg in "$@" +do + if [ "$arg" == "--no-cache" ] + then + ARGS="${ARGS} --no-cache" + fi +done + # Rewrite docker-compose ./script/docker_update_version.py --version=${ERPLIBRE_VERSION} --base=${ERPLIBRE_DOCKER_BASE} --prod=${ERPLIBRE_DOCKER_PROD} cd docker -ARGS=--build-arg=WORKING_BRANCH=$(git rev-parse --abbrev-ref HEAD) - -# Clear cache -# ARGS="${ARGS} --no-cache" +ARGS="${ARGS} --build-arg=WORKING_BRANCH=$(git rev-parse --abbrev-ref HEAD)" set -e