bob
bob copied to clipboard
Docker compose restart behaviour
closes https://github.com/benchkram/bob/issues/98
This PR also fixes the issue with rebuild not happening after a restart
Check if the behavior is correct when a init is in progress. It should most likely block the restart request till init is done => https://github.com/benchkram/bob/blob/main/bobrun/wrap.go#L97
A restart must be able to be cancable (by listening to the context as we do it with build).. E.g. A restart is immediately followed by a ctrl+c (send SIGINT).. this should stop the restart and allow shutdown to start as fast as possible.
A restart must be able to be cancable (by listening to the context as we do it with build).. E.g. A restart is immediately followed by a ctrl+c (send SIGINT).. this should stop the restart and allow shutdown to start as fast as possible.
It looks like it already is if I'm not mistaken. How I tested:
In /pkg/execctl/cmd.go
, I changed Restart() method with:
// Restart first interrupts the command if it's already running, and then re-runs the command.
func (c *Cmd) Restart() error {
err := c.stop()
if err != nil {
return err
}
err = c.Wait()
if err != nil {
return err
}
fmt.Println("sleeping")
time.Sleep(20 * time.Second)
fmt.Println("done")
return c.Start()
}
On the bob/example/server-db
I did a restart and CTRL+R.
Result:
The exec command from above will not start and then everything is shutting down.
Testing wait for init to finish before restarting
- In example/server-db add init to the server run task:
run:
server:
type: binary
path: ./build/server
dependson:
- build
- database
init: "echo initstart\nsleep 10s\n echo donewithinit"
database:
type: compose
path: docker-compose.yml
- Add some logs in:
pkg/execctl/cmd.go bobrun/compose.go
where restart is happening.
-
Run
bob run server
-
Hit CTRL-R to restart in the 10s interval while the init cmd is running
-
Should restart only after init is done.The ouput of init should be before the logs added in the cmd and compose
Tested it as you described. Seems that restart is not waiting for init to be finished.. It also doesn't execute init again after subsequent restarts.
I found another bug. CTRL+R
seems not to trigger a rebuild. Do a change in example/server-db/main.go
and do a restart.
bob build
does a rebuild .. CTRL+R
misses this.
Closing for now, focus is currently on build