mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Cowyo works as a single binary now
This commit is contained in:
parent
2c687f79ca
commit
3f3ee6c9fa
@ -13,6 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func serve(port string) {
|
func serve(port string) {
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
router.HTMLRender = loadTemplates("index.tmpl")
|
router.HTMLRender = loadTemplates("index.tmpl")
|
||||||
// router.Use(static.Serve("/static/", static.LocalFile("./static", true)))
|
// router.Use(static.Serve("/static/", static.LocalFile("./static", true)))
|
||||||
|
7
main.go
7
main.go
@ -48,8 +48,12 @@ func main() {
|
|||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
Usage: "start a cowyo server",
|
Usage: "start a cowyo server",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
if !c.GlobalBool("debug") {
|
||||||
|
turnOffDebugger()
|
||||||
|
}
|
||||||
pathToData = c.GlobalString("data")
|
pathToData = c.GlobalString("data")
|
||||||
os.MkdirAll(pathToData, 0755)
|
os.MkdirAll(pathToData, 0755)
|
||||||
|
fmt.Printf("\nRunning CowYo at http://%s:%s\n\n", GetLocalIP(), c.GlobalString("port"))
|
||||||
serve(c.GlobalString("port"))
|
serve(c.GlobalString("port"))
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -59,6 +63,9 @@ func main() {
|
|||||||
Aliases: []string{"m"},
|
Aliases: []string{"m"},
|
||||||
Usage: "migrate from the old cowyo",
|
Usage: "migrate from the old cowyo",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
if !c.GlobalBool("debug") {
|
||||||
|
turnOffDebugger()
|
||||||
|
}
|
||||||
pathToData = c.GlobalString("data")
|
pathToData = c.GlobalString("data")
|
||||||
pathToOldData := c.GlobalString("olddata")
|
pathToOldData := c.GlobalString("olddata")
|
||||||
if len(pathToOldData) == 0 {
|
if len(pathToOldData) == 0 {
|
||||||
|
4
utils.go
4
utils.go
@ -35,6 +35,10 @@ func init() {
|
|||||||
log = lumber.NewConsoleLogger(lumber.TRACE)
|
log = lumber.NewConsoleLogger(lumber.TRACE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func turnOffDebugger() {
|
||||||
|
log = lumber.NewConsoleLogger(lumber.WARN)
|
||||||
|
}
|
||||||
|
|
||||||
func randomAnimal() string {
|
func randomAnimal() string {
|
||||||
return strings.Replace(strings.Title(animals[rand.Intn(len(animals)-1)]), " ", "", -1)
|
return strings.Replace(strings.Title(animals[rand.Intn(len(animals)-1)]), " ", "", -1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user