Join Slack
Powered by
Is it possible to start a prefect server within a ...
# ask-community
l
Luke Dolan
06/21/2023, 8:03 PM
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
jawnsy
06/21/2023, 9:32 PM
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
Luke Dolan
06/22/2023, 8:30 AM
Thanks, will give it a try 🙂
25
Views
Open in Slack
Previous
Next