Fix NameError and add feature flag for scheduler
- Restored start_scheduler() function that was missing - Added DISABLE_SCHEDULER feature flag check in main() - App should start now without scheduler running - Fixed 500 Internal Server Error russell@unturf.com is the boss
This commit is contained in:
parent
266493ae8e
commit
96f6a926be
2 changed files with 24 additions and 3 deletions
|
|
@ -63,7 +63,7 @@ deploy:
|
|||
|
||||
[Service]
|
||||
WorkingDirectory=${APP_DIR}
|
||||
Environment="PATH=${VENV_DIR}/bin"
|
||||
Environment="PATH=${VENV_DIR}/bin" "DISABLE_SCHEDULER=true"
|
||||
ExecStart=${VENV_DIR}/bin/uwsgi \\
|
||||
--master \\
|
||||
--enable-threads \\
|
||||
|
|
|
|||
25
app.py
25
app.py
|
|
@ -889,6 +889,23 @@ def check_and_run_scheduler():
|
|||
log.error(f"On-demand scheduler error: {e}")
|
||||
|
||||
|
||||
def start_scheduler():
|
||||
"""Start the background scheduler."""
|
||||
global scheduler_thread, scheduler_running
|
||||
|
||||
# Check if scheduler is disabled via environment variable
|
||||
disable_scheduler = os.environ.get('DISABLE_SCHEDULER', '').lower() in ('true', '1', 'yes')
|
||||
if disable_scheduler:
|
||||
log.info("Scheduler disabled by DISABLE_SCHEDULER environment variable")
|
||||
return
|
||||
|
||||
if not scheduler_running:
|
||||
scheduler_running = True
|
||||
scheduler_thread = threading.Thread(target=scheduler_worker, daemon=True)
|
||||
scheduler_thread.start()
|
||||
log.info("Scheduler started")
|
||||
|
||||
|
||||
def stop_scheduler():
|
||||
"""Stop the background scheduler."""
|
||||
global scheduler_thread, scheduler_running
|
||||
|
|
@ -2313,8 +2330,12 @@ def main(*config, **settings):
|
|||
|
||||
config.scan()
|
||||
|
||||
# Start the scheduler
|
||||
start_scheduler()
|
||||
# Start the scheduler (with feature flag)
|
||||
disable_scheduler = os.environ.get('DISABLE_SCHEDULER', '').lower() in ('true', '1', 'yes')
|
||||
if not disable_scheduler:
|
||||
start_scheduler()
|
||||
else:
|
||||
log.info("Scheduler disabled by DISABLE_SCHEDULER environment variable")
|
||||
|
||||
return config.make_wsgi_app()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue