Setup Prefect agent as background process
# ask-community
s
I’m trying to sort out how to run prefect agents as background processes. Running an agent alone interactively works well (connects with work queue perfectly). But then I tried to run as a background process using supervisor via systemctl, and the agent is running, but it’s not connected to the work queue previously created - the work queue in the app.prefect.cloud UI is in an unhealthy state. Any troubleshooting tips?
1
ah,
Ephemeral API
… needed to set
PREFECT_API_URL
and
PREFECT_API_KEY
n
yep, wherever the agent runs will need those env vars to be set so it can communicate with cloud (or your instance of the server) here's a setup guide if you haven't seen it
👍 2
s
Related-ish question: Any guidelines on how many agents to use?
n
I'd say that it depends highly on your objectives / runtime infra, but generally I'd say agents are 1 to 1 with execution environments
s
thanks!