mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-04-03 03:27:13 +08:00
Convert debug to bool
This commit is contained in:
parent
3191ac9ab6
commit
2ea8c465c8
@ -24,6 +24,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/pagefaultgames/rogueserver/api"
|
"github.com/pagefaultgames/rogueserver/api"
|
||||||
"github.com/pagefaultgames/rogueserver/db"
|
"github.com/pagefaultgames/rogueserver/db"
|
||||||
@ -31,17 +32,19 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// flag stuff
|
// flag stuff
|
||||||
debug := os.Getenv("debug")
|
debug, errDebugBoolParse := strconv.ParseBool(os.Getenv("debug"))
|
||||||
|
if errDebugBoolParse != nil {
|
||||||
proto = "tcp"
|
log.Fatalf("failed to parse debug value: %s", errDebugBoolParse)
|
||||||
addr = "0.0.0.0:8001"
|
}
|
||||||
|
proto := "tcp"
|
||||||
|
addr := "0.0.0.0:8001"
|
||||||
|
|
||||||
|
|
||||||
dbuser = os.Getenv("dbuser")
|
dbuser := os.Getenv("dbuser")
|
||||||
dbpass = os.Getenv("dbpass")
|
dbpass := os.Getenv("dbpass")
|
||||||
dbproto = "tcp"
|
dbproto := "tcp"
|
||||||
dbaddr = os.Getenv("dbaddr")
|
dbaddr := os.Getenv("dbaddr")
|
||||||
dbname = os.Getenv("dbname")
|
dbname := os.Getenv("dbname")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -50,13 +53,13 @@ func main() {
|
|||||||
gob.Register(map[string]interface{}{})
|
gob.Register(map[string]interface{}{})
|
||||||
|
|
||||||
// get database connection
|
// get database connection
|
||||||
err := db.Init(*dbuser, *dbpass, *dbproto, *dbaddr, *dbname)
|
err := db.Init(dbuser, dbpass, dbproto, dbaddr, dbname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to initialize database: %s", err)
|
log.Fatalf("failed to initialize database: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// create listener
|
// create listener
|
||||||
listener, err := createListener(*proto, *addr)
|
listener, err := createListener(proto, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to create net listener: %s", err)
|
log.Fatalf("failed to create net listener: %s", err)
|
||||||
}
|
}
|
||||||
@ -67,7 +70,7 @@ func main() {
|
|||||||
api.Init(mux)
|
api.Init(mux)
|
||||||
|
|
||||||
// start web server
|
// start web server
|
||||||
if *debug {
|
if debug == true {
|
||||||
err = http.Serve(listener, debugHandler(mux))
|
err = http.Serve(listener, debugHandler(mux))
|
||||||
} else {
|
} else {
|
||||||
err = http.Serve(listener, mux)
|
err = http.Serve(listener, mux)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user