package main import ( "fmt" "log" "net/http" "net/url" "os" "mDoc/admin" "mDoc/tools" ) func main() { port := tools.InterfaceToStr(tools.If(os.Getenv("PORT") == "", "9000", os.Getenv("PORT"))) // 环境变量亦可以设置服务端口 adminMux := admin.InitApp() adminServer := &http.Server{ Addr: ":" + port, Handler: adminMux, } // 管理服务 go adminServer.ListenAndServe() fmt.Println("Admiin Served at http://localhost:" + port + "/admin") // 公共服务 u, _ := url.Parse(os.Getenv("PUBLISH_URL")) publishPort := tools.InterfaceToStr(tools.If(u.Port() == "", "9001", u.Port())) publishMux := http.FileServer(http.Dir(admin.PublishDir)) publishServer := &http.Server{ Addr: ":" + publishPort, Handler: publishMux, } fmt.Println("Publish Served at http://localhost:" + publishPort) log.Fatal(publishServer.ListenAndServe()) }