Skip to content

Commit

Permalink
Use preload for routines
Browse files Browse the repository at this point in the history
  • Loading branch information
sondregronas committed Jul 26, 2024
1 parent b36a640 commit c2d0681
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
6 changes: 2 additions & 4 deletions BookingSystem/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,10 @@ def debug_login() -> flask.Response:

init_db()
Settings.verify_settings_exist()
start_routine()

return app


app = create_app()

if __name__ == '__main__':
app.run(host='0.0.0.0')
start_routine()
create_app().run(host='0.0.0.0')
3 changes: 0 additions & 3 deletions BookingSystem/routine_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ def start_routine():
logger.info("Skipping routine tasks in testing environment")
return

if os.getpid() != int(os.getenv('GUNICORN_PID')):
return

def _task(job_func):
try:
job_func()
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ run_app() {
cp -r /overrides/* /app;
fi

gunicorn --bind 0.0.0.0:5000 -t 60 app:app &
gunicorn --bind 0.0.0.0:5000 --preload routine_tasks:start_routine() -t 60 app:create_app() &
PID=$!
wait $PID
}
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ MarkupSafe==2.1.5
pymsteams==0.2.2
flask-compress==1.15
schedule==1.2.2
gunicorn==22.0.0

0 comments on commit c2d0681

Please sign in to comment.