-
-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APScheduler logs not showing in docker #227
Comments
Made some progress on this.. looks like preload is working but I'm having some weird behavior with the logs When I start the scheduler inside the @app.on_event("startup")
async def on_startup():
# Startup db
await init_db()
# Configure Logs
if not os.environ.get("LOG_LEVEL"):
os.environ["LOG_LEVEL"] = "INFO"
setup_logger_from_settings(
LoggingSettings(
level=os.environ.get("LOG_LEVEL"),
filepath=os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"config",
"log.log",
),
)
)
# Setup Scheduler
scheduler = AsyncIOScheduler()
scheduler.add_job(manage_portfolio_task, "interval", seconds=10)
scheduler.add_job(fetch_liquidity_changes, "interval", minutes=5)
scheduler.start()
# For local dev
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
However when I run it outside of this startup function (which I need to otherwise all of the uvicorn workers will duplicate the scheduler), I do not see these logs showing the job logs when they are run if not os.environ.get("LOG_LEVEL"):
os.environ["LOG_LEVEL"] = "INFO"
setup_logger_from_settings(
LoggingSettings(
level=os.environ.get("LOG_LEVEL"),
filepath=os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"config",
"log.log",
),
)
)
# Setup Scheduler
scheduler = AsyncIOScheduler()
scheduler.add_job(manage_portfolio_task, "interval", seconds=10)
scheduler.add_job(fetch_liquidity_changes, "interval", minutes=5)
scheduler.start()
# Configure DB
@app.on_event("startup")
async def on_startup():
# Startup db
await init_db()
# For local dev
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
How can I get the workers logs to show so that way if there are any errors I would still be able to see them? |
The jobs spin up fine when I run locally, but when I run through docker, each of the workers duplicates the jobs
From research I've done, the workaround around is to
preload
the app, however when I try to do this both from the CLI or custom guincorn_conf.py file (setting preload_app=True), I am still experiencing the duplication.When moving the following code outside of the
on_statup()
function or inside theif __name__ == "__main__":
block, the scheduler does not seem to start at allThe text was updated successfully, but these errors were encountered: