mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Persist instance state after starting and stopping instances
This commit is contained in:
@@ -210,6 +210,13 @@ func (im *instanceManager) StartInstance(name string) (*Instance, error) {
|
|||||||
return nil, fmt.Errorf("failed to start instance %s: %w", name, err)
|
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
|
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)
|
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
|
return instance, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user