From 3afc959d369a082fecda2c2fb2c107a767ec0e46 Mon Sep 17 00:00:00 2001 From: nixpig <143995476+nixpig@users.noreply.github.com> Date: Thu, 12 Dec 2024 05:32:11 +0000 Subject: [PATCH] chore: move running state update --- container/container_reexec1.go | 29 ----------------------------- container/container_start.go | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/container/container_reexec1.go b/container/container_reexec1.go index 87c89df..9e6701a 100644 --- a/container/container_reexec1.go +++ b/container/container_reexec1.go @@ -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 { diff --git a/container/container_start.go b/container/container_start.go index 81c8b1b..c881a92 100644 --- a/container/container_start.go +++ b/container/container_start.go @@ -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 }