2020-04-13 00:06:13 -04:00
|
|
|
#!/usr/bin/env bash
|
2024-02-23 13:01:10 -05:00
|
|
|
Red='\033[0;31m' # Red
|
|
|
|
|
Color_Off='\033[0m' # Text Reset
|
2021-07-01 00:52:15 -04:00
|
|
|
|
2025-05-05 04:43:13 -04:00
|
|
|
# Search by default local configuration
|
2021-07-01 00:52:15 -04:00
|
|
|
CONFIG_PATH="./config.conf"
|
|
|
|
|
ORIGIN_CONFIG_PATH=CONFIG_PATH
|
|
|
|
|
if [ ! -f "${CONFIG_PATH}" ]; then
|
|
|
|
|
CONFIG_PATH="/etc/odoo/odoo.conf"
|
|
|
|
|
if [ ! -f "${CONFIG_PATH}" ]; then
|
2024-02-23 13:01:10 -05:00
|
|
|
echo "${Red}Cannot find${Color_Off} ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install"
|
2021-07-01 00:52:15 -04:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
[ADD] run: choisir la base au démarrage, sans jamais bloquer
« ./run.sh » sans argument partait sans base et l'on choisissait dans le
gestionnaire web. Il choisit maintenant : une seule base, il démarre
dessus ; plusieurs, il affiche un menu numéroté.
Ce qui décide n'est pas le menu mais l'endroit où il ne doit PAS s'ouvrir.
systemd écrit « ExecStart=/bin/bash …/run.sh » sans argument, avec
Restart=always : une question posée là serait une boucle de redémarrage.
Le défaut implicite exige donc un terminal sur stdin ET sur stderr — pas
stdout, qui est toujours un tube dans la substitution qui nous lit.
Mesuré : sans terminal, la ligne d'arguments est identique à l'octet et
la sonde, qui coûte 0,8 s, n'est jamais appelée.
--- EN ---
« ./run.sh » with no argument started without a database and one picked
in the web manager. It now picks: a single database, it starts on it;
several, it shows a numbered menu.
What decides is not the menu but where it must NOT open. systemd writes
« ExecStart=/bin/bash …/run.sh » with no argument and Restart=always: a
question asked there would be a restart loop. The implicit default
therefore requires a terminal on stdin AND on stderr — not stdout, which
is always a pipe inside the substitution that reads us. Measured: with no
terminal the argument line is byte-for-byte identical and the 0.8 s probe
is never called.
Assisted-by: Claude Opus 5
2026-08-23 17:26:41 -04:00
|
|
|
# Deux options qui appartiennent à ERPLibre, retirées avant de passer la
|
|
|
|
|
# main : Odoo ne les connaît pas et mourrait sur « no such option ».
|
|
|
|
|
# --auto-erplibre arme le choix de la base à démarrer
|
|
|
|
|
# --no-cli-erplibre interdit le menu, sans interdire le choix
|
[ADD] run : précharger le registre Odoo au lancement, sans nuire
Odoo ne charge le registre d'une base qu'à la PREMIÈRE requête : sur une
base migrée, la personne qui ouvre la page attend des dizaines de secondes.
La sonde prend ce temps à sa place et s'arrête à la première réponse : un
303, un 404 ou un 500 prouvent tous que le registre est chargé.
Elle ne peut pas nuire : elle rend TOUJOURS 0, meurt avec run.sh par un trap
et abandonne après deux minutes. Le port vient de la ligne de commande, puis
de config.conf, puis du journal, exact même quand le port demandé était pris ;
l'écoute sur une interface vide ou générale est sondée par le bouclage.
`--erplibre-disable-warmup-http` la coupe, et elle seule est RETIRÉE avant
odoo_bin.sh, qu'Odoo refuse ; `--no-http` et `--stop-after-init` aussi.
--- EN ---
Odoo only loads a database's registry on the FIRST request: on a migrated
database, whoever opens the page waits tens of seconds. The probe takes that
time instead and stops at the first answer: a 303, a 404 or a 500 all prove
the registry is loaded.
It cannot get in the way: it ALWAYS returns 0, dies with run.sh through a
trap and gives up after two minutes. The port comes from the command line,
then config.conf, then the log, exact even when the requested port was taken;
an empty or wildcard listen interface is probed on the loopback.
`--erplibre-disable-warmup-http` turns it off, and it alone is STRIPPED
before odoo_bin.sh, which Odoo rejects; `--no-http` and `--stop-after-init` too.
Assisted-by: Claude Opus 5
(cherry picked from commit d0943782029ac9a23830d8a8041fccbcac98b67d)
2026-08-25 05:28:02 -04:00
|
|
|
# --erplibre-disable-warmup-http n'envoie pas la requête de réveil
|
[ADD] run: choisir la base au démarrage, sans jamais bloquer
« ./run.sh » sans argument partait sans base et l'on choisissait dans le
gestionnaire web. Il choisit maintenant : une seule base, il démarre
dessus ; plusieurs, il affiche un menu numéroté.
Ce qui décide n'est pas le menu mais l'endroit où il ne doit PAS s'ouvrir.
systemd écrit « ExecStart=/bin/bash …/run.sh » sans argument, avec
Restart=always : une question posée là serait une boucle de redémarrage.
Le défaut implicite exige donc un terminal sur stdin ET sur stderr — pas
stdout, qui est toujours un tube dans la substitution qui nous lit.
Mesuré : sans terminal, la ligne d'arguments est identique à l'octet et
la sonde, qui coûte 0,8 s, n'est jamais appelée.
--- EN ---
« ./run.sh » with no argument started without a database and one picked
in the web manager. It now picks: a single database, it starts on it;
several, it shows a numbered menu.
What decides is not the menu but where it must NOT open. systemd writes
« ExecStart=/bin/bash …/run.sh » with no argument and Restart=always: a
question asked there would be a restart loop. The implicit default
therefore requires a terminal on stdin AND on stderr — not stdout, which
is always a pipe inside the substitution that reads us. Measured: with no
terminal the argument line is byte-for-byte identical and the 0.8 s probe
is never called.
Assisted-by: Claude Opus 5
2026-08-23 17:26:41 -04:00
|
|
|
# Sans AUCUN argument, le choix s'arme de lui-même : c'est « make run »,
|
|
|
|
|
# quelqu'un devant son terminal. Ce défaut-là reste timide — il exige un
|
|
|
|
|
# terminal des deux côtés — parce que systemd lance lui aussi run.sh sans
|
|
|
|
|
# argument, avec Restart=always.
|
|
|
|
|
EL_ARGS=()
|
|
|
|
|
EL_AUTO=0
|
|
|
|
|
EL_AUTO_EXPLICITE=0
|
|
|
|
|
EL_NO_CLI=0
|
[ADD] run : précharger le registre Odoo au lancement, sans nuire
Odoo ne charge le registre d'une base qu'à la PREMIÈRE requête : sur une
base migrée, la personne qui ouvre la page attend des dizaines de secondes.
La sonde prend ce temps à sa place et s'arrête à la première réponse : un
303, un 404 ou un 500 prouvent tous que le registre est chargé.
Elle ne peut pas nuire : elle rend TOUJOURS 0, meurt avec run.sh par un trap
et abandonne après deux minutes. Le port vient de la ligne de commande, puis
de config.conf, puis du journal, exact même quand le port demandé était pris ;
l'écoute sur une interface vide ou générale est sondée par le bouclage.
`--erplibre-disable-warmup-http` la coupe, et elle seule est RETIRÉE avant
odoo_bin.sh, qu'Odoo refuse ; `--no-http` et `--stop-after-init` aussi.
--- EN ---
Odoo only loads a database's registry on the FIRST request: on a migrated
database, whoever opens the page waits tens of seconds. The probe takes that
time instead and stops at the first answer: a 303, a 404 or a 500 all prove
the registry is loaded.
It cannot get in the way: it ALWAYS returns 0, dies with run.sh through a
trap and gives up after two minutes. The port comes from the command line,
then config.conf, then the log, exact even when the requested port was taken;
an empty or wildcard listen interface is probed on the loopback.
`--erplibre-disable-warmup-http` turns it off, and it alone is STRIPPED
before odoo_bin.sh, which Odoo rejects; `--no-http` and `--stop-after-init` too.
Assisted-by: Claude Opus 5
(cherry picked from commit d0943782029ac9a23830d8a8041fccbcac98b67d)
2026-08-25 05:28:02 -04:00
|
|
|
EL_WARMUP=1
|
[ADD] run: choisir la base au démarrage, sans jamais bloquer
« ./run.sh » sans argument partait sans base et l'on choisissait dans le
gestionnaire web. Il choisit maintenant : une seule base, il démarre
dessus ; plusieurs, il affiche un menu numéroté.
Ce qui décide n'est pas le menu mais l'endroit où il ne doit PAS s'ouvrir.
systemd écrit « ExecStart=/bin/bash …/run.sh » sans argument, avec
Restart=always : une question posée là serait une boucle de redémarrage.
Le défaut implicite exige donc un terminal sur stdin ET sur stderr — pas
stdout, qui est toujours un tube dans la substitution qui nous lit.
Mesuré : sans terminal, la ligne d'arguments est identique à l'octet et
la sonde, qui coûte 0,8 s, n'est jamais appelée.
--- EN ---
« ./run.sh » with no argument started without a database and one picked
in the web manager. It now picks: a single database, it starts on it;
several, it shows a numbered menu.
What decides is not the menu but where it must NOT open. systemd writes
« ExecStart=/bin/bash …/run.sh » with no argument and Restart=always: a
question asked there would be a restart loop. The implicit default
therefore requires a terminal on stdin AND on stderr — not stdout, which
is always a pipe inside the substitution that reads us. Measured: with no
terminal the argument line is byte-for-byte identical and the 0.8 s probe
is never called.
Assisted-by: Claude Opus 5
2026-08-23 17:26:41 -04:00
|
|
|
[ $# -eq 0 ] && EL_AUTO=1
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
--auto-erplibre)
|
|
|
|
|
EL_AUTO=1
|
|
|
|
|
EL_AUTO_EXPLICITE=1
|
|
|
|
|
;;
|
|
|
|
|
--no-cli-erplibre) EL_NO_CLI=1 ;;
|
[ADD] run : précharger le registre Odoo au lancement, sans nuire
Odoo ne charge le registre d'une base qu'à la PREMIÈRE requête : sur une
base migrée, la personne qui ouvre la page attend des dizaines de secondes.
La sonde prend ce temps à sa place et s'arrête à la première réponse : un
303, un 404 ou un 500 prouvent tous que le registre est chargé.
Elle ne peut pas nuire : elle rend TOUJOURS 0, meurt avec run.sh par un trap
et abandonne après deux minutes. Le port vient de la ligne de commande, puis
de config.conf, puis du journal, exact même quand le port demandé était pris ;
l'écoute sur une interface vide ou générale est sondée par le bouclage.
`--erplibre-disable-warmup-http` la coupe, et elle seule est RETIRÉE avant
odoo_bin.sh, qu'Odoo refuse ; `--no-http` et `--stop-after-init` aussi.
--- EN ---
Odoo only loads a database's registry on the FIRST request: on a migrated
database, whoever opens the page waits tens of seconds. The probe takes that
time instead and stops at the first answer: a 303, a 404 or a 500 all prove
the registry is loaded.
It cannot get in the way: it ALWAYS returns 0, dies with run.sh through a
trap and gives up after two minutes. The port comes from the command line,
then config.conf, then the log, exact even when the requested port was taken;
an empty or wildcard listen interface is probed on the loopback.
`--erplibre-disable-warmup-http` turns it off, and it alone is STRIPPED
before odoo_bin.sh, which Odoo rejects; `--no-http` and `--stop-after-init` too.
Assisted-by: Claude Opus 5
(cherry picked from commit d0943782029ac9a23830d8a8041fccbcac98b67d)
2026-08-25 05:28:02 -04:00
|
|
|
--erplibre-disable-warmup-http) EL_WARMUP=0 ;;
|
|
|
|
|
# Rien à réveiller si personne n'écoute. On les laisse passer à Odoo,
|
|
|
|
|
# on se contente de ne pas sonder.
|
|
|
|
|
--no-http|--stop-after-init)
|
|
|
|
|
EL_WARMUP=0
|
|
|
|
|
EL_ARGS+=("$1")
|
|
|
|
|
;;
|
[ADD] run: choisir la base au démarrage, sans jamais bloquer
« ./run.sh » sans argument partait sans base et l'on choisissait dans le
gestionnaire web. Il choisit maintenant : une seule base, il démarre
dessus ; plusieurs, il affiche un menu numéroté.
Ce qui décide n'est pas le menu mais l'endroit où il ne doit PAS s'ouvrir.
systemd écrit « ExecStart=/bin/bash …/run.sh » sans argument, avec
Restart=always : une question posée là serait une boucle de redémarrage.
Le défaut implicite exige donc un terminal sur stdin ET sur stderr — pas
stdout, qui est toujours un tube dans la substitution qui nous lit.
Mesuré : sans terminal, la ligne d'arguments est identique à l'octet et
la sonde, qui coûte 0,8 s, n'est jamais appelée.
--- EN ---
« ./run.sh » with no argument started without a database and one picked
in the web manager. It now picks: a single database, it starts on it;
several, it shows a numbered menu.
What decides is not the menu but where it must NOT open. systemd writes
« ExecStart=/bin/bash …/run.sh » with no argument and Restart=always: a
question asked there would be a restart loop. The implicit default
therefore requires a terminal on stdin AND on stderr — not stdout, which
is always a pipe inside the substitution that reads us. Measured: with no
terminal the argument line is byte-for-byte identical and the 0.8 s probe
is never called.
Assisted-by: Claude Opus 5
2026-08-23 17:26:41 -04:00
|
|
|
# Tout le reste passe tel quel, y compris les arguments vides et ceux
|
|
|
|
|
# qui portent des espaces : un tableau, jamais une chaîne reconstruite.
|
|
|
|
|
*) EL_ARGS+=("$1") ;;
|
|
|
|
|
esac
|
|
|
|
|
shift
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
EL_DB=()
|
|
|
|
|
EL_LIB="./script/database/lib_db_select.sh"
|
|
|
|
|
if [ "${EL_AUTO}" = "1" ] && [ -f "${EL_LIB}" ]; then
|
|
|
|
|
# shellcheck source=script/database/lib_db_select.sh
|
|
|
|
|
. "${EL_LIB}"
|
|
|
|
|
EL_DB_NAME="$(el_db_select "${CONFIG_PATH}" "${EL_NO_CLI}" \
|
|
|
|
|
"${EL_AUTO_EXPLICITE}" "${EL_ARGS[@]}")"
|
|
|
|
|
retSelect=$?
|
|
|
|
|
# 130 : on a renoncé au menu. Ne pas démarrer Odoo pour autant, et ne pas
|
|
|
|
|
# rendre 1 non plus — run.sh:26 réserve déjà 1 à « Odoo a échoué ».
|
|
|
|
|
if [ ${retSelect} -eq 130 ]; then
|
|
|
|
|
exit 130
|
|
|
|
|
fi
|
|
|
|
|
if [ -n "${EL_DB_NAME}" ]; then
|
|
|
|
|
EL_DB=(-d "${EL_DB_NAME}")
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
[ADD] run : précharger le registre Odoo au lancement, sans nuire
Odoo ne charge le registre d'une base qu'à la PREMIÈRE requête : sur une
base migrée, la personne qui ouvre la page attend des dizaines de secondes.
La sonde prend ce temps à sa place et s'arrête à la première réponse : un
303, un 404 ou un 500 prouvent tous que le registre est chargé.
Elle ne peut pas nuire : elle rend TOUJOURS 0, meurt avec run.sh par un trap
et abandonne après deux minutes. Le port vient de la ligne de commande, puis
de config.conf, puis du journal, exact même quand le port demandé était pris ;
l'écoute sur une interface vide ou générale est sondée par le bouclage.
`--erplibre-disable-warmup-http` la coupe, et elle seule est RETIRÉE avant
odoo_bin.sh, qu'Odoo refuse ; `--no-http` et `--stop-after-init` aussi.
--- EN ---
Odoo only loads a database's registry on the FIRST request: on a migrated
database, whoever opens the page waits tens of seconds. The probe takes that
time instead and stops at the first answer: a 303, a 404 or a 500 all prove
the registry is loaded.
It cannot get in the way: it ALWAYS returns 0, dies with run.sh through a
trap and gives up after two minutes. The port comes from the command line,
then config.conf, then the log, exact even when the requested port was taken;
an empty or wildcard listen interface is probed on the loopback.
`--erplibre-disable-warmup-http` turns it off, and it alone is STRIPPED
before odoo_bin.sh, which Odoo rejects; `--no-http` and `--stop-after-init` too.
Assisted-by: Claude Opus 5
(cherry picked from commit d0943782029ac9a23830d8a8041fccbcac98b67d)
2026-08-25 05:28:02 -04:00
|
|
|
# Le réveil, EN PARALLÈLE. Odoo ne charge le registre d'une base qu'à la
|
|
|
|
|
# première requête qui la concerne ; sur une base migrée cela prend des
|
|
|
|
|
# dizaines de secondes, et c'est la personne qui ouvre la page qui les
|
|
|
|
|
# attend. La sonde prend ce temps à sa place, se tait, et meurt avec nous.
|
|
|
|
|
EL_WARMUP_PID=""
|
|
|
|
|
EL_WARMUP_BIN="./script/odoo/warmup_http.py"
|
|
|
|
|
if [ "${EL_WARMUP}" = "1" ] && [ "$ODOO_MODE_TEST" != "true" ] \
|
|
|
|
|
&& [ -f "${EL_WARMUP_BIN}" ]; then
|
|
|
|
|
EL_WARMUP_DB=()
|
|
|
|
|
[ -n "${EL_DB_NAME}" ] && EL_WARMUP_DB=(-d "${EL_DB_NAME}")
|
|
|
|
|
# `--` sépare NOS options de celles d'Odoo : sans lui, un « -c » destiné
|
|
|
|
|
# à Odoo serait lu comme le nôtre.
|
|
|
|
|
python3 "${EL_WARMUP_BIN}" -c "${CONFIG_PATH}" "${EL_WARMUP_DB[@]}" \
|
|
|
|
|
-- "${EL_ARGS[@]}" 2>/dev/null &
|
|
|
|
|
EL_WARMUP_PID=$!
|
|
|
|
|
# Elle ne doit pas survivre au serveur qu'elle réveille. Un Ctrl-C sur
|
|
|
|
|
# run.sh doit tout emporter.
|
|
|
|
|
trap '[ -n "${EL_WARMUP_PID}" ] && kill "${EL_WARMUP_PID}" 2>/dev/null' EXIT
|
|
|
|
|
fi
|
|
|
|
|
|
2025-05-04 23:10:34 -04:00
|
|
|
if [ "$ODOO_MODE_TEST" = "true" ]; then
|
[ADD] run: choisir la base au démarrage, sans jamais bloquer
« ./run.sh » sans argument partait sans base et l'on choisissait dans le
gestionnaire web. Il choisit maintenant : une seule base, il démarre
dessus ; plusieurs, il affiche un menu numéroté.
Ce qui décide n'est pas le menu mais l'endroit où il ne doit PAS s'ouvrir.
systemd écrit « ExecStart=/bin/bash …/run.sh » sans argument, avec
Restart=always : une question posée là serait une boucle de redémarrage.
Le défaut implicite exige donc un terminal sur stdin ET sur stderr — pas
stdout, qui est toujours un tube dans la substitution qui nous lit.
Mesuré : sans terminal, la ligne d'arguments est identique à l'octet et
la sonde, qui coûte 0,8 s, n'est jamais appelée.
--- EN ---
« ./run.sh » with no argument started without a database and one picked
in the web manager. It now picks: a single database, it starts on it;
several, it shows a numbered menu.
What decides is not the menu but where it must NOT open. systemd writes
« ExecStart=/bin/bash …/run.sh » with no argument and Restart=always: a
question asked there would be a restart loop. The implicit default
therefore requires a terminal on stdin AND on stderr — not stdout, which
is always a pipe inside the substitution that reads us. Measured: with no
terminal the argument line is byte-for-byte identical and the 0.8 s probe
is never called.
Assisted-by: Claude Opus 5
2026-08-23 17:26:41 -04:00
|
|
|
./odoo_bin.sh -c "${CONFIG_PATH}" --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-hard=0 --log-level=test --test-enable --no-http --stop-after-init "${EL_DB[@]}" "${EL_ARGS[@]}"
|
2025-05-04 23:10:34 -04:00
|
|
|
else
|
[ADD] run: choisir la base au démarrage, sans jamais bloquer
« ./run.sh » sans argument partait sans base et l'on choisissait dans le
gestionnaire web. Il choisit maintenant : une seule base, il démarre
dessus ; plusieurs, il affiche un menu numéroté.
Ce qui décide n'est pas le menu mais l'endroit où il ne doit PAS s'ouvrir.
systemd écrit « ExecStart=/bin/bash …/run.sh » sans argument, avec
Restart=always : une question posée là serait une boucle de redémarrage.
Le défaut implicite exige donc un terminal sur stdin ET sur stderr — pas
stdout, qui est toujours un tube dans la substitution qui nous lit.
Mesuré : sans terminal, la ligne d'arguments est identique à l'octet et
la sonde, qui coûte 0,8 s, n'est jamais appelée.
--- EN ---
« ./run.sh » with no argument started without a database and one picked
in the web manager. It now picks: a single database, it starts on it;
several, it shows a numbered menu.
What decides is not the menu but where it must NOT open. systemd writes
« ExecStart=/bin/bash …/run.sh » with no argument and Restart=always: a
question asked there would be a restart loop. The implicit default
therefore requires a terminal on stdin AND on stderr — not stdout, which
is always a pipe inside the substitution that reads us. Measured: with no
terminal the argument line is byte-for-byte identical and the 0.8 s probe
is never called.
Assisted-by: Claude Opus 5
2026-08-23 17:26:41 -04:00
|
|
|
./odoo_bin.sh -c "${CONFIG_PATH}" --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-hard=0 "${EL_DB[@]}" "${EL_ARGS[@]}"
|
2025-05-04 23:10:34 -04:00
|
|
|
fi
|
2023-04-09 22:23:21 -04:00
|
|
|
# When need more memory RAM for instance by force
|
|
|
|
|
#python3 ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-soft=8589934592 --limit-memory-hard=10737418240 $@
|
|
|
|
|
|
2021-06-27 00:22:22 -04:00
|
|
|
retVal=$?
|
|
|
|
|
if [[ $retVal -ne 0 ]]; then
|
2024-02-23 13:01:10 -05:00
|
|
|
echo "${Red}Error${Color_Off} run.sh"
|
2021-07-01 00:52:15 -04:00
|
|
|
exit 1
|
2021-06-27 00:22:22 -04:00
|
|
|
fi
|