Added flag to start with live http profiler
This commit is contained in:
parent
e562e2fefb
commit
2707294bb6
21
main.go
21
main.go
@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"time"
|
"time"
|
||||||
@ -18,6 +19,7 @@ var verbose = flag.Bool("verbose", false, "")
|
|||||||
var width = flag.Float64("width", 800, "width of field")
|
var width = flag.Float64("width", 800, "width of field")
|
||||||
var height = flag.Float64("height", 550, "height of field")
|
var height = flag.Float64("height", 550, "height of field")
|
||||||
var profile = flag.String("pprof", "", "if specified will run with pprof")
|
var profile = flag.String("pprof", "", "if specified will run with pprof")
|
||||||
|
var netprofile = flag.Bool("netprof", false, "if specified will run with net/http/pprof")
|
||||||
var debug = flag.Bool("debug", false, "automatically create games if they don't exist")
|
var debug = flag.Bool("debug", false, "automatically create games if they don't exist")
|
||||||
|
|
||||||
var delta float32
|
var delta float32
|
||||||
@ -39,19 +41,26 @@ func main() {
|
|||||||
}
|
}
|
||||||
pprof.StartCPUProfile(f)
|
pprof.StartCPUProfile(f)
|
||||||
}
|
}
|
||||||
|
if *netprofile {
|
||||||
|
go func() {
|
||||||
|
log.Println(http.ListenAndServe("localhost:8667", nil))
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
games = MapLock{m: make(map[string]*game)}
|
games = MapLock{m: make(map[string]*game)}
|
||||||
idg = NewIdGenerator()
|
idg = NewIdGenerator()
|
||||||
|
|
||||||
delta = (float32(*tick) / 1000.0) * float32(*timescale)
|
delta = (float32(*tick) / 1000.0) * float32(*timescale)
|
||||||
|
|
||||||
http.Handle("/ws/", websocket.Handler(addPlayer))
|
sm := http.NewServeMux()
|
||||||
http.Handle("/game/start/", JsonHandler(startGame))
|
|
||||||
http.Handle("/game/list/", JsonHandler(listGames))
|
|
||||||
http.HandleFunc("/game/stop/", stopGame)
|
|
||||||
http.HandleFunc("/fuck/shit/up/", killServer)
|
|
||||||
|
|
||||||
err := http.ListenAndServe(*addr, nil)
|
sm.Handle("/ws/", websocket.Handler(addPlayer))
|
||||||
|
sm.Handle("/game/start/", JsonHandler(startGame))
|
||||||
|
sm.Handle("/game/list/", JsonHandler(listGames))
|
||||||
|
sm.HandleFunc("/game/stop/", stopGame)
|
||||||
|
sm.HandleFunc("/fuck/shit/up/", killServer)
|
||||||
|
|
||||||
|
err := http.ListenAndServe(*addr, sm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("unable to start server")
|
log.Fatal("unable to start server")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user