mirror of https://github.com/gin-gonic/gin.git
42 lines
714 B
Go
42 lines
714 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/manucorporat/stats"
|
|
)
|
|
|
|
var messages = stats.New()
|
|
|
|
func main() {
|
|
ConfigRuntime()
|
|
StartWorkers()
|
|
StartGin()
|
|
}
|
|
|
|
func ConfigRuntime() {
|
|
nuCPU := runtime.NumCPU()
|
|
runtime.GOMAXPROCS(nuCPU)
|
|
fmt.Printf("Running with %d CPUs\n", nuCPU)
|
|
}
|
|
|
|
func StartWorkers() {
|
|
go statsWorker()
|
|
}
|
|
|
|
func StartGin() {
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
router := gin.Default()
|
|
router.LoadHTMLGlob("resources/*.templ.html")
|
|
router.Static("/static", "resources/static")
|
|
router.GET("/", index)
|
|
router.GET("/room/:roomid", roomGET)
|
|
router.POST("/room-post/:roomid", roomPOST)
|
|
router.GET("/stream/:roomid", streamRoom)
|
|
|
|
router.Run("127.0.0.1:8080")
|
|
}
|