Is it possible to start a prefect server within a ...
# ask-community
l
Is it possible to start a prefect server within a python .py without calling subprocess.popen? I would like to avoid having a shell script / calling shell commands
j
I think you can do something with uvicorn and running the app directly, but I think the reason we do subprocess.popen has something uvicorn and signal handling. The standard OSS disclaimer applies in that case: if you break something, you get to keep both pieces :) The FastAPI app is created here, I think you can create it directly and then pass it to uvicorn: https://github.com/PrefectHQ/prefect/blob/fe331da61f275cb67d7684e3ec155085bbb8cbbe/src/prefect/server/api/server.py#L411-L415 This is the command to create a uvicorn server programmatically: https://www.uvicorn.org/#uvicornrun
l
Thanks, will give it a try 🙂