Thread
#prefect-community
    b

    Bastian Röhrig

    10 months ago
    Hey everyone, we have a docker agent running on a cloud vm for our production workloads. We need to automatically restart the docker agent on reboot. Is there a recommended way to make that happen? I stumbled across the https://docs.prefect.io/orchestration/agents/local.html#using-with-supervisor supervisor feature for local agent and am thinking about adapting this for our use case. However, I do not know enough of Supervisor to know if that would be the right approach.
    Anna Geller

    Anna Geller

    10 months ago
    @Bastian Röhrig good question - overall local agent and Docker agent both run as a local process, so you can absolutely use the same Supervisor configuration as for a local agent. You need to only adjust the startup command. When you run:
    prefect agent local install
    , this will output an example
    supervisord.conf
    config file. You can then copy all that and change:
    [program:prefect-agent]
    command=prefect agent local start
    to your agent configuration:
    [program:prefect-agent]
    command=prefect agent docker start --label YOUR_LABEL
    b

    Bastian Röhrig

    10 months ago
    Thank you, that sounds good 🙂 We will do it like that
    Emma Rizzi

    Emma Rizzi

    9 months ago
    Hi @Bastian Röhrig ! I'm trying to do exactly the same, did you manage to do it ? I have to create a custom VM image and as a complete noob in this field I try to gather as much advice as possible!
    Anna Geller

    Anna Geller

    9 months ago
    @Emma Rizzi perhaps you can try first on your local machine? what we do here is a simple supervisor config to make sure the agent process runs in background and is restarted if it gets shut down for some reason
    Emma Rizzi

    Emma Rizzi

    9 months ago
    @Anna Geller i see it might not be exactly what I need, I'll open a new thread to not spam here!
    Aram Panasenco

    Aram Panasenco

    9 months ago
    An alternative to using Supervisor is using Docker's own restart policies that you can use to always restart a container if it stops for any reason: https://docs.docker.com/engine/reference/commandline/run/#restart-policies---restart