Add timeout check interval and update instance configuration

This commit is contained in:
2025-08-17 19:26:21 +02:00
parent 902be409d5
commit ccffbca6b2
4 changed files with 34 additions and 22 deletions

View File

@@ -182,6 +182,7 @@ instances:
default_auto_restart: true # Default auto-restart setting
default_max_restarts: 3 # Default maximum restart attempts
default_restart_delay: 5 # Default restart delay in seconds
timeout_check_interval: 5 # Default instance timeout check interval in minutes
```
**Environment Variables:**
@@ -195,6 +196,7 @@ instances:
- `LLAMACTL_DEFAULT_AUTO_RESTART` - Default auto-restart setting (true/false)
- `LLAMACTL_DEFAULT_MAX_RESTARTS` - Default maximum restarts
- `LLAMACTL_DEFAULT_RESTART_DELAY` - Default restart delay in seconds
- `LLAMACTL_TIMEOUT_CHECK_INTERVAL` - Default instance timeout check interval in minutes
#### Authentication Configuration

View File

@@ -66,6 +66,9 @@ type InstancesConfig struct {
// Default restart delay for new instances (in seconds)
DefaultRestartDelay int `yaml:"default_restart_delay"`
// Interval for checking instance timeouts (in minutes)
TimeoutCheckInterval int `yaml:"timeout_check_interval"`
}
// AuthConfig contains authentication settings
@@ -108,6 +111,7 @@ func LoadConfig(configPath string) (AppConfig, error) {
DefaultAutoRestart: true,
DefaultMaxRestarts: 3,
DefaultRestartDelay: 5,
TimeoutCheckInterval: 5, // Check timeouts every 5 minutes
},
Auth: AuthConfig{
RequireInferenceAuth: true,
@@ -217,6 +221,11 @@ func loadEnvVars(cfg *AppConfig) {
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
if requireInferenceAuth := os.Getenv("LLAMACTL_REQUIRE_INFERENCE_AUTH"); requireInferenceAuth != "" {
if b, err := strconv.ParseBool(requireInferenceAuth); err == nil {

View File

@@ -124,7 +124,7 @@ func validateAndCopyOptions(name string, options *CreateInstanceOptions) *Create
if options.IdleTimeout != nil {
idleTimeout := *options.IdleTimeout
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
}
optionsCopy.IdleTimeout = &idleTimeout
@@ -156,7 +156,7 @@ func applyDefaultOptions(options *CreateInstanceOptions, globalSettings *config.
}
if options.IdleTimeout == nil {
defaultIdleTimeout := 0 // Default to 0 seconds if not set
defaultIdleTimeout := 0
options.IdleTimeout = &defaultIdleTimeout
}
}

1
pkg/instance/timeout.go Normal file
View File

@@ -0,0 +1 @@
package instance