mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 09:04:27 +00:00
Add DefaultOnDemandStart configuration and update instance options
This commit is contained in:
@@ -67,6 +67,9 @@ type InstancesConfig struct {
|
|||||||
// Default restart delay for new instances (in seconds)
|
// Default restart delay for new instances (in seconds)
|
||||||
DefaultRestartDelay int `yaml:"default_restart_delay"`
|
DefaultRestartDelay int `yaml:"default_restart_delay"`
|
||||||
|
|
||||||
|
// Default on-demand start setting for new instances
|
||||||
|
DefaultOnDemandStart bool `yaml:"default_on_demand_start"`
|
||||||
|
|
||||||
// Interval for checking instance timeouts (in minutes)
|
// Interval for checking instance timeouts (in minutes)
|
||||||
TimeoutCheckInterval int `yaml:"timeout_check_interval"`
|
TimeoutCheckInterval int `yaml:"timeout_check_interval"`
|
||||||
}
|
}
|
||||||
@@ -111,6 +114,7 @@ func LoadConfig(configPath string) (AppConfig, error) {
|
|||||||
DefaultAutoRestart: true,
|
DefaultAutoRestart: true,
|
||||||
DefaultMaxRestarts: 3,
|
DefaultMaxRestarts: 3,
|
||||||
DefaultRestartDelay: 5,
|
DefaultRestartDelay: 5,
|
||||||
|
DefaultOnDemandStart: false,
|
||||||
TimeoutCheckInterval: 5, // Check timeouts every 5 minutes
|
TimeoutCheckInterval: 5, // Check timeouts every 5 minutes
|
||||||
},
|
},
|
||||||
Auth: AuthConfig{
|
Auth: AuthConfig{
|
||||||
@@ -221,6 +225,11 @@ func loadEnvVars(cfg *AppConfig) {
|
|||||||
cfg.Instances.DefaultRestartDelay = seconds
|
cfg.Instances.DefaultRestartDelay = seconds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if onDemandStart := os.Getenv("LLAMACTL_DEFAULT_ON_DEMAND_START"); onDemandStart != "" {
|
||||||
|
if b, err := strconv.ParseBool(onDemandStart); err == nil {
|
||||||
|
cfg.Instances.DefaultOnDemandStart = b
|
||||||
|
}
|
||||||
|
}
|
||||||
if timeoutCheckInterval := os.Getenv("LLAMACTL_TIMEOUT_CHECK_INTERVAL"); timeoutCheckInterval != "" {
|
if timeoutCheckInterval := os.Getenv("LLAMACTL_TIMEOUT_CHECK_INTERVAL"); timeoutCheckInterval != "" {
|
||||||
if minutes, err := strconv.Atoi(timeoutCheckInterval); err == nil {
|
if minutes, err := strconv.Atoi(timeoutCheckInterval); err == nil {
|
||||||
cfg.Instances.TimeoutCheckInterval = minutes
|
cfg.Instances.TimeoutCheckInterval = minutes
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ type CreateInstanceOptions struct {
|
|||||||
AutoRestart *bool `json:"auto_restart,omitempty"`
|
AutoRestart *bool `json:"auto_restart,omitempty"`
|
||||||
MaxRestarts *int `json:"max_restarts,omitempty"`
|
MaxRestarts *int `json:"max_restarts,omitempty"`
|
||||||
RestartDelay *int `json:"restart_delay,omitempty"`
|
RestartDelay *int `json:"restart_delay,omitempty"`
|
||||||
// Timeout
|
// On demand start
|
||||||
|
OnDemandStart *bool `json:"on_demand_start,omitempty"`
|
||||||
|
// Idle timeout
|
||||||
IdleTimeout *int `json:"idle_timeout,omitempty"`
|
IdleTimeout *int `json:"idle_timeout,omitempty"`
|
||||||
// LlamaServerOptions contains the options for the llama server
|
// LlamaServerOptions contains the options for the llama server
|
||||||
llamacpp.LlamaServerOptions `json:",inline"`
|
llamacpp.LlamaServerOptions `json:",inline"`
|
||||||
@@ -49,6 +51,7 @@ func (c *CreateInstanceOptions) UnmarshalJSON(data []byte) error {
|
|||||||
AutoRestart *bool `json:"auto_restart,omitempty"`
|
AutoRestart *bool `json:"auto_restart,omitempty"`
|
||||||
MaxRestarts *int `json:"max_restarts,omitempty"`
|
MaxRestarts *int `json:"max_restarts,omitempty"`
|
||||||
RestartDelay *int `json:"restart_delay,omitempty"`
|
RestartDelay *int `json:"restart_delay,omitempty"`
|
||||||
|
OnDemandStart *bool `json:"on_demand_start,omitempty"`
|
||||||
IdleTimeout *int `json:"idle_timeout,omitempty"`
|
IdleTimeout *int `json:"idle_timeout,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +64,7 @@ func (c *CreateInstanceOptions) UnmarshalJSON(data []byte) error {
|
|||||||
c.AutoRestart = temp.AutoRestart
|
c.AutoRestart = temp.AutoRestart
|
||||||
c.MaxRestarts = temp.MaxRestarts
|
c.MaxRestarts = temp.MaxRestarts
|
||||||
c.RestartDelay = temp.RestartDelay
|
c.RestartDelay = temp.RestartDelay
|
||||||
|
c.OnDemandStart = temp.OnDemandStart
|
||||||
c.IdleTimeout = temp.IdleTimeout
|
c.IdleTimeout = temp.IdleTimeout
|
||||||
|
|
||||||
// Now unmarshal the embedded LlamaServerOptions
|
// Now unmarshal the embedded LlamaServerOptions
|
||||||
@@ -138,6 +142,11 @@ func validateAndCopyOptions(name string, options *CreateInstanceOptions) *Create
|
|||||||
optionsCopy.RestartDelay = &restartDelay
|
optionsCopy.RestartDelay = &restartDelay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.OnDemandStart != nil {
|
||||||
|
onDemandStart := *options.OnDemandStart
|
||||||
|
optionsCopy.OnDemandStart = &onDemandStart
|
||||||
|
}
|
||||||
|
|
||||||
if options.IdleTimeout != nil {
|
if options.IdleTimeout != nil {
|
||||||
idleTimeout := *options.IdleTimeout
|
idleTimeout := *options.IdleTimeout
|
||||||
if idleTimeout < 0 {
|
if idleTimeout < 0 {
|
||||||
@@ -172,6 +181,11 @@ func applyDefaultOptions(options *CreateInstanceOptions, globalSettings *config.
|
|||||||
options.RestartDelay = &defaultRestartDelay
|
options.RestartDelay = &defaultRestartDelay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.OnDemandStart == nil {
|
||||||
|
defaultOnDemandStart := globalSettings.DefaultOnDemandStart
|
||||||
|
options.OnDemandStart = &defaultOnDemandStart
|
||||||
|
}
|
||||||
|
|
||||||
if options.IdleTimeout == nil {
|
if options.IdleTimeout == nil {
|
||||||
defaultIdleTimeout := 0
|
defaultIdleTimeout := 0
|
||||||
options.IdleTimeout = &defaultIdleTimeout
|
options.IdleTimeout = &defaultIdleTimeout
|
||||||
|
|||||||
Reference in New Issue
Block a user