main.go 771 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. "net/url"
  7. "os"
  8. "mDoc/admin"
  9. )
  10. func main() {
  11. // CMS server
  12. port := os.Getenv("PORT")
  13. if port == "" {
  14. port = "9000"
  15. }
  16. cmsMux := admin.InitApp()
  17. cmsServer := &http.Server{
  18. Addr: ":" + port,
  19. Handler: cmsMux,
  20. }
  21. go cmsServer.ListenAndServe()
  22. fmt.Println("CMS Served at http://localhost:" + port + "/admin")
  23. // Publish server
  24. u, _ := url.Parse(os.Getenv("PUBLISH_URL"))
  25. publishPort := u.Port()
  26. if publishPort == "" {
  27. publishPort = "9001"
  28. }
  29. publishMux := http.FileServer(http.Dir(admin.PublishDir))
  30. publishServer := &http.Server{
  31. Addr: ":" + publishPort,
  32. Handler: publishMux,
  33. }
  34. fmt.Println("Publish Served at http://localhost:" + publishPort)
  35. log.Fatal(publishServer.ListenAndServe())
  36. }