mirror of
https://github.com/mudler/LocalAI.git
synced 2026-04-04 23:14:41 -04:00
feat: Add --data-path CLI flag for persistent data separation (#8888)
feat: add --data-path CLI flag for persistent data separation - Add LOCALAI_DATA_PATH environment variable and --data-path CLI flag - Default data path: /data (separate from configuration directory) - Automatic migration on startup: moves agent_tasks.json, agent_jobs.json, collections/, and assets/ from old config dir to new data path - Backward compatible: preserves old behavior if LOCALAI_DATA_PATH is not set - Agent state and job directories now use DataPath with proper fallback chain - Update documentation with new flag and docker-compose example This separates mutable persistent data (collectiondb, agents, assets, skills) from configuration files, enabling better volume mounting and data persistence in containerized deployments. Signed-off-by: localai-bot <localai-bot@noreply.github.com> Co-authored-by: localai-bot <localai-bot@noreply.github.com>
This commit is contained in:
@@ -93,11 +93,16 @@ func NewAgentJobService(
|
||||
retentionDays = 30 // Default
|
||||
}
|
||||
|
||||
// Determine storage directory: DataPath > DynamicConfigsDir
|
||||
tasksFile := ""
|
||||
jobsFile := ""
|
||||
if appConfig.DynamicConfigsDir != "" {
|
||||
tasksFile = filepath.Join(appConfig.DynamicConfigsDir, "agent_tasks.json")
|
||||
jobsFile = filepath.Join(appConfig.DynamicConfigsDir, "agent_jobs.json")
|
||||
dataDir := appConfig.DataPath
|
||||
if dataDir == "" {
|
||||
dataDir = appConfig.DynamicConfigsDir
|
||||
}
|
||||
if dataDir != "" {
|
||||
tasksFile = filepath.Join(dataDir, "agent_tasks.json")
|
||||
jobsFile = filepath.Join(dataDir, "agent_jobs.json")
|
||||
}
|
||||
|
||||
return &AgentJobService{
|
||||
|
||||
@@ -64,8 +64,11 @@ func (s *AgentPoolService) Start(ctx context.Context) error {
|
||||
apiKey = s.appConfig.ApiKeys[0]
|
||||
}
|
||||
|
||||
// State dir defaults to DynamicConfigsDir (LocalAI configuration folder)
|
||||
// State dir: explicit config > DataPath > DynamicConfigsDir > fallback
|
||||
stateDir := cfg.StateDir
|
||||
if stateDir == "" {
|
||||
stateDir = s.appConfig.DataPath
|
||||
}
|
||||
if stateDir == "" {
|
||||
stateDir = s.appConfig.DynamicConfigsDir
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user