rocketry-with-fastapi
rocketry-with-fastapi copied to clipboard
Application does not close on ctrl+c
I am trying to kill the server and the rocketry app. But when I press ctrl+c only the server is killed. I am already using the custom class provided.
import asyncio
import logging
from api import app as app_fastapi
from scheduler import app as app_rocketry
@app_fastapi.on_event('startup')
async def on_startup():
logger = logging.getLogger('rocketry.task')
logger.addHandler(logging.StreamHandler())
asyncio.create_task(app_rocketry.serve())
@app_fastapi.on_event('shutdown')
def on_shutdown():
print('shutdown')
app_rocketry.session.shut_down()
I change the main.py file to this.
Thanks for noting this! I suppose this (the on_event
) perhaps a feature made to FastAPI after I made the template. I have plans to update the template with the "bigger application setup" when I'm done with latest features of Rocketry. I'll add this then.