Restart local agent

I had set up a local agent to run different flows but for a few days, the local agent goes to unhealthy state for no reason. Is there a way to restart the local agent from Perfect cloud 2?

I run my local agent inside of a shell script which restarts it on failure. If you can ensure your agent will actually fail when this condition is met, this might help. I have run.sh contain the actual agent invocation.

#!/bin/bash

cd "$(dirname "$0")"
echo "In dir: " `pwd`
poetry update

while true; do
  bash ./run.sh
  echo "In dir: " `pwd`

  echo "Prefect Agent crashed! with exit $?. Restarting.." >&2
  sleep 1
done
1 Like

Thank you. I have a local agent running on a windows system with a .bat file. I modify the .bat script with a while loop that restart the agent when it stops. For now seems to work…