From a9b50df0c53a02907dad191790a9e714dbc3d572 Mon Sep 17 00:00:00 2001 From: Jared Kipe Date: Fri, 10 Dec 2021 10:54:14 -0800 Subject: [PATCH] Athene odoo-reload foreground. --- .theia/launch.json | 16 ++++++++++++++++ odoo-reload.py | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 odoo-reload.py diff --git a/.theia/launch.json b/.theia/launch.json index 59373190..a43ff192 100644 --- a/.theia/launch.json +++ b/.theia/launch.json @@ -27,6 +27,22 @@ "-u", "sale", "--test-enable", "--no-xmlrpc", "--stop-after-init"], "console": "integratedTerminal" + }, + { + "name": "Odoo: server", + "type": "python", + "request": "launch", + "program": "/opt/odoo/hibou-suite/odoo-run.py", + "args": [], + "console": "integratedTerminal" + }, + { + "name": "Odoo: reload foreground server", + "type": "python", + "request": "launch", + "program": "/opt/odoo/hibou-suite/odoo-reload.py", + "args": [], + "console": "integratedTerminal" } ] } diff --git a/odoo-reload.py b/odoo-reload.py new file mode 100755 index 00000000..c84471ab --- /dev/null +++ b/odoo-reload.py @@ -0,0 +1,24 @@ +import psutil +import os +import signal + +PID = 1 +PNAME = 'odoo' +is_foreground = False +for proc in psutil.process_iter(): + try: + process_name = proc.name() + process_id = proc.pid + if process_id == PID: + is_foreground = process_name == PNAME + break + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + pass + +if not is_foreground: + print('Odoo is not the foreground process.') + exit(-1) + +print('Signalling reload to Odoo') +os.kill(PID, signal.SIGHUP) +