art: Allow the agent to self-restart on error

In init systems that don't support automatic restart this might be handy when we fail because we boot up too fast.

This is an attempt to fix https://github.com/c3os-io/c3os/issues/47
This commit is contained in:
Ettore Di Giacinto 2022-08-08 08:15:15 +00:00 committed by Itxaka
parent c8244f7dbd
commit fe08c577ed

View File

@ -100,6 +100,9 @@ Starts the c3os agent which automatically bootstrap and advertize to the c3os ne
`,
Aliases: []string{"s"},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "restart",
},
&cli.BoolFlag{
Name: "force",
},
@ -115,7 +118,20 @@ Starts the c3os agent which automatically bootstrap and advertize to the c3os ne
dirs = args
}
return agent.Run(c.String("api"), dirs, c.Bool("force"))
opts := []agent.Option{
agent.WithAPI(c.String("api")),
agent.WithDirectory(dirs...),
}
if c.Bool("force") {
opts = append(opts, agent.ForceAgent)
}
if c.Bool("restart") {
opts = append(opts, agent.RestartAgent)
}
return agent.Run(opts...)
},
},
{