from waitress import serve from app import app, scheduler, clean_old_logs import atexit with app.app_context(): scheduler.add_job(func=clean_old_logs, trigger="interval", days=1) atexit.register(lambda: scheduler.shutdown()) serve(app, host='0.0.0.0', port=5582, ident='', threads=4)