Commit 9297ff83 authored by Michael Yang's avatar Michael Yang
Browse files

fix OLLAMA_HOST parsing for ip6

parent ee4fd16f
...@@ -655,28 +655,19 @@ func generateBatch(cmd *cobra.Command, model string) error { ...@@ -655,28 +655,19 @@ func generateBatch(cmd *cobra.Command, model string) error {
} }
func RunServer(cmd *cobra.Command, _ []string) error { func RunServer(cmd *cobra.Command, _ []string) error {
host, port := "127.0.0.1", "11434" host, port, err := net.SplitHostPort(os.Getenv("OLLAMA_HOST"))
if err != nil {
parts := strings.Split(os.Getenv("OLLAMA_HOST"), ":") host, port = "127.0.0.1", "11434"
if ip := net.ParseIP(parts[0]); ip != nil { if ip := net.ParseIP(os.Getenv("OLLAMA_HOST")); ip != nil {
host = ip.String() host = ip.String()
} }
if len(parts) > 1 {
port = parts[1]
}
// deprecated: include port in OLLAMA_HOST
if p := os.Getenv("OLLAMA_PORT"); p != "" {
port = p
} }
err := initializeKeypair() if err := initializeKeypair(); err != nil {
if err != nil {
return err return err
} }
ln, err := net.Listen("tcp", fmt.Sprintf("%s:%s", host, port)) ln, err := net.Listen("tcp", net.JoinHostPort(host, port))
if err != nil { if err != nil {
return err return err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment