Persist instance state after starting and stopping instances

This commit is contained in:
2025-08-02 21:23:31 +02:00
parent de89d0673a
commit d449255bc9

View File

@@ -210,6 +210,13 @@ func (im *instanceManager) StartInstance(name string) (*Instance, error) {
return nil, fmt.Errorf("failed to start instance %s: %w", name, err)
}
im.mu.Lock()
defer im.mu.Unlock()
err := im.persistInstance(instance)
if err != nil {
return nil, fmt.Errorf("failed to persist instance %s: %w", name, err)
}
return instance, nil
}
@@ -230,6 +237,13 @@ func (im *instanceManager) StopInstance(name string) (*Instance, error) {
return nil, fmt.Errorf("failed to stop instance %s: %w", name, err)
}
im.mu.Lock()
defer im.mu.Unlock()
err := im.persistInstance(instance)
if err != nil {
return nil, fmt.Errorf("failed to persist instance %s: %w", name, err)
}
return instance, nil
}