Prefect Agent as Windows Service

Has anyone had success setting up the running of a Prefect agent on a local machine as a Windows service? I would’ve expected this to be the most robust way of making sure any unexpected failure of the agent process would result in a restart, but having fought with it now for a few hours using various approaches (nssm.exe, wswin.exe, etc.), I can’t seem to get my work queue to see the agent and run my flows.

What is the recommended practice for running an agent upon starting up the box with the ability to restart upon failure on a Windows machine?

Peter,

I was able to run Prefect Orion UI and an Agent using NSSM. Here are my example commands.

nssm install “Prefect Orion UI” “C:\ProgramData\Anaconda3\envs\spc-prefect-2.7.10\Scripts\prefect.exe” “orion start”
nssm remove “Prefect Orion UI”

nssm install “Prefect Orion Agent (data-feeds)” “C:\ProgramData\Anaconda3\envs\spc-prefect-2.7.10\Scripts\prefect.exe” “agent start --work-queue data-feeds”
nssm remove “Prefect Orion Agent (data-feeds)”

1 Like

Hi Matthew, you solution works like a charm! Thank you.