Is your feature request related to a problem? Please describe.
When using lifespan events for executing code on startup or shutdown of a VM, like described in the FastAPI Docs, then this will work on apps being run with uvicorn, but not when deployed on Aleph.
Describe the solution you'd like
On-demand, as well as persistent VMs, should have their ASGI lifespan events invoked.
Ideally, we can autodetect lifespan events like in Uvicorn
Lifespan events should belong to the code subject to timeout requirements and may be interrupted if not respecting those
Describe alternatives you've considered
Optionally add a "lifespan" config for VMs to explicitly enforce that these events are being sent to the VM or not
Stop VM execution if lifespan.startup failed and "lifespan" config is set to true
Additional context
Currently, timeouts are realized at the firecracker_microvm.py level:
This should be rather on the VmExecution level, given that we might also use other VM jailers. If for any reason startup and shutdown procedures are taking longer than expected, then this should not go "unbilled".
Is your feature request related to a problem? Please describe. When using lifespan events for executing code on startup or shutdown of a VM, like described in the FastAPI Docs, then this will work on apps being run with uvicorn, but not when deployed on Aleph.
Describe the solution you'd like
Describe alternatives you've considered
lifespan.startup
failed and "lifespan" config is set totrue
Additional context Currently, timeouts are realized at the
firecracker_microvm.py
level:This should be rather on the
VmExecution
level, given that we might also use other VM jailers. If for any reason startup and shutdown procedures are taking longer than expected, then this should not go "unbilled".