You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/cmd/api/main.go

34 lines
849 B

4 years ago
package main
import (
2 years ago
"OpenIM/internal/api"
"OpenIM/pkg/common/config"
"OpenIM/pkg/common/log"
4 years ago
"flag"
3 years ago
"fmt"
4 years ago
"strconv"
2 years ago
"OpenIM/pkg/common/constant"
4 years ago
)
func main() {
2 years ago
if err := config.InitConfig(); err != nil {
2 years ago
panic(err.Error())
}
2 years ago
log.NewPrivateLog(constant.LogFileName)
router := api.NewGinRouter()
2 years ago
ginPort := flag.Int("port", config.Config.Api.GinPort[0], "get ginServerPort from cmd,default 10002 as port")
flag.Parse()
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
if config.Config.Api.ListenIP != "" {
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
}
2 years ago
fmt.Println("start api server, address: ", address, ", OpenIM version: ", constant.CurrentVersion)
2 years ago
err := router.Run(address)
3 years ago
if err != nil {
2 years ago
log.Error("", "api run failed ", address, err.Error())
panic("api start failed " + err.Error())
3 years ago
}
4 years ago
}