From 63470385638ac478fa748e17b9998ccec0de088c Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 22 Mar 2017 13:19:00 -0600 Subject: [PATCH] Cowyo works as a single binary now Former-commit-id: e3c11510f61564a5f8c6a53d9d9bd768c5fa0f17 [formerly 8c3e635c3cfd2f00acbe4fe4c89b5c9921c3a4ba] [formerly ed287ec86da7ff501a972dcb68f9a0045dcb3798 [formerly b2ea068629093bbeebca0be37f463701117a5d1b [formerly 3f3ee6c9fabae91f487148ebe618470c8d99360f]]] Former-commit-id: 049fac69946d4e4a7866d28afa0999bac8457840 [formerly 4451a7e8d278d70f1547f4ade77df8f9ef76b0d3] Former-commit-id: 3a8a4d9ab222d9d23ebf6981e0553a28a123a08f Former-commit-id: 70616e9d31a0890eb8466c8f67c603ce33810c7a --- handlers.go | 1 + main.go | 7 +++++++ utils.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/handlers.go b/handlers.go index 7c6ab57..ef0493b 100755 --- a/handlers.go +++ b/handlers.go @@ -13,6 +13,7 @@ import ( ) func serve(port string) { + gin.SetMode(gin.ReleaseMode) router := gin.Default() router.HTMLRender = loadTemplates("index.tmpl") // router.Use(static.Serve("/static/", static.LocalFile("./static", true))) diff --git a/main.go b/main.go index 6eb63f0..30fa428 100755 --- a/main.go +++ b/main.go @@ -48,8 +48,12 @@ func main() { Aliases: []string{"s"}, Usage: "start a cowyo server", Action: func(c *cli.Context) error { + if !c.GlobalBool("debug") { + turnOffDebugger() + } pathToData = c.GlobalString("data") os.MkdirAll(pathToData, 0755) + fmt.Printf("\nRunning CowYo at http://%s:%s\n\n", GetLocalIP(), c.GlobalString("port")) serve(c.GlobalString("port")) return nil }, @@ -59,6 +63,9 @@ func main() { Aliases: []string{"m"}, Usage: "migrate from the old cowyo", Action: func(c *cli.Context) error { + if !c.GlobalBool("debug") { + turnOffDebugger() + } pathToData = c.GlobalString("data") pathToOldData := c.GlobalString("olddata") if len(pathToOldData) == 0 { diff --git a/utils.go b/utils.go index de60f3e..b5f257a 100644 --- a/utils.go +++ b/utils.go @@ -35,6 +35,10 @@ func init() { log = lumber.NewConsoleLogger(lumber.TRACE) } +func turnOffDebugger() { + log = lumber.NewConsoleLogger(lumber.WARN) +} + func randomAnimal() string { return strings.Replace(strings.Title(animals[rand.Intn(len(animals)-1)]), " ", "", -1) }