rocketry-with-fastapi icon indicating copy to clipboard operation
rocketry-with-fastapi copied to clipboard

Application does not close on ctrl+c

Open carlosporta opened this issue 2 years ago • 2 comments

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.

carlosporta avatar Oct 17 '22 14:10 carlosporta

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.

carlosporta avatar Oct 17 '22 15:10 carlosporta

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.

Miksus avatar Oct 18 '22 06:10 Miksus