diff --git a/.dev/Procfile b/.dev/Procfile index 61049a4..4fdb8f4 100644 --- a/.dev/Procfile +++ b/.dev/Procfile @@ -1 +1,2 @@ -trytond: while true; do trytond -d ${DB_NAME} --dev -v -c $SCRIPT_DIR/trytond.cfg; done \ No newline at end of file +trytond: while true; do trytond -d ${DB_NAME} --dev -v -c $SCRIPT_DIR/trytond.cfg; done +monitor: python3 $SCRIPT_DIR/dev.py \ No newline at end of file diff --git a/.dev/dev.py b/.dev/dev.py index c53e2fb..5585171 100644 --- a/.dev/dev.py +++ b/.dev/dev.py @@ -2,9 +2,12 @@ import sys import os import logging +import time import inotify.adapters +logging.basicConfig(level=logging.INFO, stream=sys.stderr) + SRC = os.environ['SRC'] MODULE_NAME = os.environ['MODULE_NAME'] DB_NAME = os.environ['DB_NAME'] @@ -18,12 +21,17 @@ def _main(): for event in i.event_gen(yield_nones=False): (_, type_names, path, filename) = event (_, ext) = os.path.splitext(filename) + if 'IN_CLOSE_WRITE' not in type_names: + continue if ext in ['.py', '.xml', '.cfg']: - if os.system("trytond-admin -d {} -u {}".format(DB_NAME, MODULE_NAME)) != 0: - print("fallo trytond-admin", file=sys.stderr) - - logging.info("ACTUALIZADO TRYTOND POR CAMBIO DE ARCHIVO %s", filename) + for _ in range(0, 10): + if os.system("trytond-admin -d {} -u {}".format(DB_NAME, MODULE_NAME)) != 0: + time.sleep(2) + logging.error("fallo trytond-admin") + else: + logging.info("ACTUALIZADO TRYTOND POR CAMBIO DE ARCHIVO %s", filename) + break if __name__ == '__main__':