mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 17:14:28 +00:00
Improve instance management
This commit is contained in:
@@ -8,10 +8,35 @@ import (
|
||||
)
|
||||
|
||||
type InstanceOptions struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty"` // Display name
|
||||
|
||||
// Auto restart
|
||||
AutoRestart bool `json:"auto_restart,omitempty"`
|
||||
MaxRestarts int `json:"max_restarts,omitempty"`
|
||||
RestartDelay int `json:"restart_delay,omitempty"` // in seconds
|
||||
|
||||
*LlamaServerOptions
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements custom JSON unmarshaling with default values
|
||||
func (o *InstanceOptions) UnmarshalJSON(data []byte) error {
|
||||
// Set defaults first
|
||||
o.AutoRestart = true
|
||||
o.MaxRestarts = 3
|
||||
o.RestartDelay = 5
|
||||
|
||||
// Create a temporary struct to avoid recursion
|
||||
type tempInstanceOptions InstanceOptions
|
||||
temp := (*tempInstanceOptions)(o)
|
||||
|
||||
// Unmarshal into the temporary struct
|
||||
if err := json.Unmarshal(data, temp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type LlamaServerOptions struct {
|
||||
// Common params
|
||||
VerbosePrompt bool `json:"verbose_prompt,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user