ensureEnv: set OLLIE_* defaults at startup
Ensure all OLLIE_* path env vars (OLLIE, OLLIE_TOOLS_PATH, OLLIE_SKILLS_PATH, OLLIE_PLAN_PATH, OLLIE_MEMORY_PATH) are set to their default values via os.Setenv before the server or any session is created. This guarantees they are visible to tool subprocesses without requiring explicit external configuration.
This commit is contained in:
parent
10a0a36681
commit
f478f7545c
18
main.go
18
main.go
|
|
@ -104,7 +104,25 @@ func stopServer(sockPath, pidPath string) {
|
|||
fmt.Println("olliesrv stopped")
|
||||
}
|
||||
|
||||
func ensureEnv() {
|
||||
home, _ := os.UserHomeDir()
|
||||
defaults := map[string]string{
|
||||
"OLLIE": filepath.Join(home, "mnt", "ollie"),
|
||||
"OLLIE_TOOLS_PATH": filepath.Join(home, ".config", "ollie", "tools"),
|
||||
"OLLIE_SKILLS_PATH": filepath.Join(home, ".config", "ollie", "skills"),
|
||||
"OLLIE_PLAN_PATH": filepath.Join(home, ".config", "ollie", "planning"),
|
||||
"OLLIE_MEMORY_PATH": filepath.Join(home, ".config", "ollie", "memory"),
|
||||
}
|
||||
for k, v := range defaults {
|
||||
if os.Getenv(k) == "" {
|
||||
os.Setenv(k, v) //nolint:errcheck
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func runServer(sockPath, pidPath string) {
|
||||
ensureEnv()
|
||||
|
||||
// Remove stale socket
|
||||
if _, err := os.Stat(sockPath); err == nil {
|
||||
os.Remove(sockPath) //nolint:errcheck
|
||||
|
|
|
|||
Reference in New Issue