Skip to content

Commit

Permalink
chore: move running state update
Browse files Browse the repository at this point in the history
  • Loading branch information
nixpig committed Dec 12, 2024
1 parent 8b4ccea commit 3afc959
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
29 changes: 0 additions & 29 deletions container/container_reexec1.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,6 @@ func (c *Container) Reexec1(log *zerolog.Logger) error {

return err
}
// if err := cmd.Start(); err != nil {
// log.Error().Err(err).Msg("🔷 failed to start container")
// c.SetStatus(specs.StateStopped)
// if err := c.Save(); err != nil {
// return fmt.Errorf("(start 1) write state file: %w", err)
// }
//
// return err
// }

c.SetStatus(specs.StateRunning)
if err := c.Save(); err != nil {
// do something with err??
log.Error().Err(err).Msg("⁉️ host save state running")
fmt.Println(err)
return fmt.Errorf("save host container state: %w", err)
}

// FIXME: do these need to move up before the cmd.Wait call??
if err := c.ExecHooks("poststart", log); err != nil {
// TODO: how to handle this (log a warning) from start command??
// FIXME: needs to 'log a warning'
log.Warn().Err(err).Msg("failed to execute poststart hook")
fmt.Println("WARNING: ", err)
}

// if err := cmd.Wait(); err != nil {
// return fmt.Errorf("waiting for cmd wait in reexec: %w", err)
// }

return nil
}); err != nil {
Expand Down
14 changes: 14 additions & 0 deletions container/container_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ func (c *Container) Start(log *zerolog.Logger) error {
return fmt.Errorf("send start over ipc: %w", err)
}
defer conn.Close()
c.SetStatus(specs.StateRunning)
if err := c.Save(); err != nil {
// do something with err??
log.Error().Err(err).Msg("⁉️ host save state running")
fmt.Println(err)
return fmt.Errorf("save host container state: %w", err)
}
// FIXME: do these need to move up before the cmd.Wait call??
if err := c.ExecHooks("poststart", log); err != nil {
// TODO: how to handle this (log a warning) from start command??
// FIXME: needs to 'log a warning'
log.Warn().Err(err).Msg("failed to execute poststart hook")
fmt.Println("WARNING: ", err)
}

return nil
}

0 comments on commit 3afc959

Please sign in to comment.