bob icon indicating copy to clipboard operation
bob copied to clipboard

Docker compose restart behaviour

Open zuzuleinen opened this issue 2 years ago • 6 comments

closes https://github.com/benchkram/bob/issues/98

This PR also fixes the issue with rebuild not happening after a restart

zuzuleinen avatar Jun 13 '22 08:06 zuzuleinen

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

Equanox avatar Jun 13 '22 09:06 Equanox

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.

Equanox avatar Jun 13 '22 10:06 Equanox

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.

zuzuleinen avatar Jun 13 '22 12:06 zuzuleinen

Testing wait for init to finish before restarting

  1. 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

  1. Add some logs in:

pkg/execctl/cmd.go bobrun/compose.go

where restart is happening.

  1. Run bob run server

  2. Hit CTRL-R to restart in the 10s interval while the init cmd is running

  3. Should restart only after init is done.The ouput of init should be before the logs added in the cmd and compose

zuzuleinen avatar Jun 14 '22 07:06 zuzuleinen

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.

image

Equanox avatar Jun 28 '22 11:06 Equanox

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.

Equanox avatar Jul 01 '22 14:07 Equanox

Closing for now, focus is currently on build

Equanox avatar Sep 26 '22 19:09 Equanox