Skip to content

Commit

Permalink
feat: custom listen port
Browse files Browse the repository at this point in the history
  • Loading branch information
missuo committed Apr 20, 2024
1 parent 7863106 commit 9a5bfde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ services:
image: ghcr.io/missuo/cohere2openai:latest
restart: always
ports:
- "6600:6600"
- "6600:6600"
22 changes: 20 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Vincent Yang
* @Date: 2024-04-16 22:58:22
* @LastEditors: Vincent Yang
* @LastEditTime: 2024-04-19 19:50:11
* @LastEditTime: 2024-04-20 06:27:48
* @FilePath: /cohere2openai/main.go
* @Telegram: https://t.me/missuo
* @GitHub: https://github.com/missuo
Expand All @@ -15,9 +15,11 @@ package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io"
"net/http"
"os"
"strings"
"time"

Expand Down Expand Up @@ -292,6 +294,22 @@ func handler(c *gin.Context) {
}

func main() {

var port string

flag.StringVar(&port, "p", "", "Port to run the server on")
flag.Parse()

if port == "" {
port = os.Getenv("PORT")
}

if port == "" {
port = "6600"
}

fmt.Println("Running on port " + port + "\nHave fun with Cohere2OpenAI!")

gin.SetMode(gin.ReleaseMode)
r := gin.Default()
r.Use(cors.Default())
Expand Down Expand Up @@ -351,5 +369,5 @@ func main() {
"message": "Path not found",
})
})
r.Run(":6600")
r.Run(":" + port)
}

0 comments on commit 9a5bfde

Please sign in to comment.