-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Centralize server config handling #4154
Conversation
server/ollamacfg/config.go
Outdated
return strings.Trim(os.Getenv(key), "\"' ") | ||
} | ||
|
||
func initCfg() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be generally be an anti-pattern but could we use init()
in this case? It might remove the need for the mutex since it the values will be initialized before the main function runs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted a bit more control on when the vars were loaded so we could have unit test cases that do os.Setenv(...)
then grab init or call other routines that need variables init'd. If we use init()
then it would read the var before we updated it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to do both - primarily init()
driven with an exposed function to reload if we want to fiddle with env vars at runtime and have them respected.
Thanks so much for doing this... some mostly cosmetic suggestions but this looks good |
dba60d5
to
afae677
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more naming suggestions but otherwise looks good
This moves all the env var reading into one central module and logs the loaded config once at startup which should help in troubleshooting user server logs
This moves all the env var reading into one central module and logs the loaded config once at startup which should help in troubleshooting user server logs
Example server output