mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Add timeout check interval and update instance configuration
This commit is contained in:
22
README.md
22
README.md
@@ -172,16 +172,17 @@ server:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
instances:
|
instances:
|
||||||
port_range: [8000, 9000] # Port range for instances (default: [8000, 9000])
|
port_range: [8000, 9000] # Port range for instances (default: [8000, 9000])
|
||||||
data_dir: "~/.local/share/llamactl" # Directory for all llamactl data (default varies by OS)
|
data_dir: "~/.local/share/llamactl" # Directory for all llamactl data (default varies by OS)
|
||||||
configs_dir: "~/.local/share/llamactl/instances" # Directory for instance configs (default: data_dir/instances)
|
configs_dir: "~/.local/share/llamactl/instances" # Directory for instance configs (default: data_dir/instances)
|
||||||
logs_dir: "~/.local/share/llamactl/logs" # Directory for instance logs (default: data_dir/logs)
|
logs_dir: "~/.local/share/llamactl/logs" # Directory for instance logs (default: data_dir/logs)
|
||||||
auto_create_dirs: true # Automatically create data/config/logs directories (default: true)
|
auto_create_dirs: true # Automatically create data/config/logs directories (default: true)
|
||||||
max_instances: -1 # Maximum instances (-1 = unlimited)
|
max_instances: -1 # Maximum instances (-1 = unlimited)
|
||||||
llama_executable: "llama-server" # Path to llama-server executable
|
llama_executable: "llama-server" # Path to llama-server executable
|
||||||
default_auto_restart: true # Default auto-restart setting
|
default_auto_restart: true # Default auto-restart setting
|
||||||
default_max_restarts: 3 # Default maximum restart attempts
|
default_max_restarts: 3 # Default maximum restart attempts
|
||||||
default_restart_delay: 5 # Default restart delay in seconds
|
default_restart_delay: 5 # Default restart delay in seconds
|
||||||
|
timeout_check_interval: 5 # Default instance timeout check interval in minutes
|
||||||
```
|
```
|
||||||
|
|
||||||
**Environment Variables:**
|
**Environment Variables:**
|
||||||
@@ -195,6 +196,7 @@ instances:
|
|||||||
- `LLAMACTL_DEFAULT_AUTO_RESTART` - Default auto-restart setting (true/false)
|
- `LLAMACTL_DEFAULT_AUTO_RESTART` - Default auto-restart setting (true/false)
|
||||||
- `LLAMACTL_DEFAULT_MAX_RESTARTS` - Default maximum restarts
|
- `LLAMACTL_DEFAULT_MAX_RESTARTS` - Default maximum restarts
|
||||||
- `LLAMACTL_DEFAULT_RESTART_DELAY` - Default restart delay in seconds
|
- `LLAMACTL_DEFAULT_RESTART_DELAY` - Default restart delay in seconds
|
||||||
|
- `LLAMACTL_TIMEOUT_CHECK_INTERVAL` - Default instance timeout check interval in minutes
|
||||||
|
|
||||||
#### Authentication Configuration
|
#### Authentication Configuration
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,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"`
|
||||||
|
|
||||||
|
// Interval for checking instance timeouts (in minutes)
|
||||||
|
TimeoutCheckInterval int `yaml:"timeout_check_interval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthConfig contains authentication settings
|
// AuthConfig contains authentication settings
|
||||||
@@ -98,16 +101,17 @@ func LoadConfig(configPath string) (AppConfig, error) {
|
|||||||
EnableSwagger: false,
|
EnableSwagger: false,
|
||||||
},
|
},
|
||||||
Instances: InstancesConfig{
|
Instances: InstancesConfig{
|
||||||
PortRange: [2]int{8000, 9000},
|
PortRange: [2]int{8000, 9000},
|
||||||
DataDir: getDefaultDataDirectory(),
|
DataDir: getDefaultDataDirectory(),
|
||||||
InstancesDir: filepath.Join(getDefaultDataDirectory(), "instances"),
|
InstancesDir: filepath.Join(getDefaultDataDirectory(), "instances"),
|
||||||
LogsDir: filepath.Join(getDefaultDataDirectory(), "logs"),
|
LogsDir: filepath.Join(getDefaultDataDirectory(), "logs"),
|
||||||
AutoCreateDirs: true,
|
AutoCreateDirs: true,
|
||||||
MaxInstances: -1, // -1 means unlimited
|
MaxInstances: -1, // -1 means unlimited
|
||||||
LlamaExecutable: "llama-server",
|
LlamaExecutable: "llama-server",
|
||||||
DefaultAutoRestart: true,
|
DefaultAutoRestart: true,
|
||||||
DefaultMaxRestarts: 3,
|
DefaultMaxRestarts: 3,
|
||||||
DefaultRestartDelay: 5,
|
DefaultRestartDelay: 5,
|
||||||
|
TimeoutCheckInterval: 5, // Check timeouts every 5 minutes
|
||||||
},
|
},
|
||||||
Auth: AuthConfig{
|
Auth: AuthConfig{
|
||||||
RequireInferenceAuth: true,
|
RequireInferenceAuth: true,
|
||||||
@@ -217,6 +221,11 @@ func loadEnvVars(cfg *AppConfig) {
|
|||||||
cfg.Instances.DefaultRestartDelay = seconds
|
cfg.Instances.DefaultRestartDelay = seconds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if timeoutCheckInterval := os.Getenv("LLAMACTL_TIMEOUT_CHECK_INTERVAL"); timeoutCheckInterval != "" {
|
||||||
|
if minutes, err := strconv.Atoi(timeoutCheckInterval); err == nil {
|
||||||
|
cfg.Instances.TimeoutCheckInterval = minutes
|
||||||
|
}
|
||||||
|
}
|
||||||
// Auth config
|
// Auth config
|
||||||
if requireInferenceAuth := os.Getenv("LLAMACTL_REQUIRE_INFERENCE_AUTH"); requireInferenceAuth != "" {
|
if requireInferenceAuth := os.Getenv("LLAMACTL_REQUIRE_INFERENCE_AUTH"); requireInferenceAuth != "" {
|
||||||
if b, err := strconv.ParseBool(requireInferenceAuth); err == nil {
|
if b, err := strconv.ParseBool(requireInferenceAuth); err == nil {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ func validateAndCopyOptions(name string, options *CreateInstanceOptions) *Create
|
|||||||
if options.IdleTimeout != nil {
|
if options.IdleTimeout != nil {
|
||||||
idleTimeout := *options.IdleTimeout
|
idleTimeout := *options.IdleTimeout
|
||||||
if idleTimeout < 0 {
|
if idleTimeout < 0 {
|
||||||
log.Printf("Instance %s IdleTimeout value (%d) cannot be negative, setting to 0 seconds", name, idleTimeout)
|
log.Printf("Instance %s IdleTimeout value (%d) cannot be negative, setting to 0 minutes", name, idleTimeout)
|
||||||
idleTimeout = 0
|
idleTimeout = 0
|
||||||
}
|
}
|
||||||
optionsCopy.IdleTimeout = &idleTimeout
|
optionsCopy.IdleTimeout = &idleTimeout
|
||||||
@@ -156,7 +156,7 @@ func applyDefaultOptions(options *CreateInstanceOptions, globalSettings *config.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if options.IdleTimeout == nil {
|
if options.IdleTimeout == nil {
|
||||||
defaultIdleTimeout := 0 // Default to 0 seconds if not set
|
defaultIdleTimeout := 0
|
||||||
options.IdleTimeout = &defaultIdleTimeout
|
options.IdleTimeout = &defaultIdleTimeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
pkg/instance/timeout.go
Normal file
1
pkg/instance/timeout.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package instance
|
||||||
Reference in New Issue
Block a user