diff --git a/BookingSystem/app.py b/BookingSystem/app.py index 42edc04..a42c626 100644 --- a/BookingSystem/app.py +++ b/BookingSystem/app.py @@ -127,14 +127,13 @@ def debug_login() -> flask.Response: Compress(app) Minify(app, static=False, go=False) # Some static files don't minify well (breaks JS) - init_db() - Settings.verify_settings_exist() - start_routine() - return app app = create_app() +init_db() +Settings.verify_settings_exist() +start_routine() # Will not run if TESTING is set to True in the environment variables if __name__ == '__main__': app.run(host='0.0.0.0') diff --git a/BookingSystem/routine_tasks.py b/BookingSystem/routine_tasks.py index 707d052..8fddc57 100644 --- a/BookingSystem/routine_tasks.py +++ b/BookingSystem/routine_tasks.py @@ -39,17 +39,11 @@ def _routine_backup(): def start_routine(): + # Skip routine tasks in testing environment if os.getenv('TESTING', 'false').lower() == 'true': logger.info("Skipping routine tasks in testing environment") return - if os.path.exists('/tmp/feideutstyrbase.pid'): - with open('/tmp/feideutstyrbase.pid', 'r') as f: - pid = int(f.read()) - if os.getpid() != pid: - logger.info("Skipping routine tasks on worker process") - return - def _task(job_func): try: job_func() diff --git a/entrypoint.sh b/entrypoint.sh index 5d3ffa9..576e3bc 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,7 +10,7 @@ run_app() { cp -r /overrides/* /app; fi - gunicorn --bind 0.0.0.0:5000 -t 60 -p /tmp/feideutstyrbase.pid app:app & + gunicorn --bind 0.0.0.0:5000 -t 60 -p /tmp/feideutstyrbase.pid --preload app:app & PID=$! wait $PID }