32 lines
651 B
Go
32 lines
651 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"gitea.com/jolheiser/beaver"
|
|
"gitea.com/jolheiser/gpm/modules/router"
|
|
"github.com/urfave/cli/v2"
|
|
"net/http"
|
|
)
|
|
|
|
var Server = cli.Command{
|
|
Name: "server",
|
|
Usage: "Start the gpm server",
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "port",
|
|
Aliases: []string{"p"},
|
|
Usage: "Port to run the gpm server on",
|
|
Value: "3333",
|
|
},
|
|
},
|
|
Action: doServer,
|
|
}
|
|
|
|
func doServer(ctx *cli.Context) error {
|
|
beaver.Infof("Running gpm server at http://localhost:%s", ctx.String("port"))
|
|
if err := http.ListenAndServe(fmt.Sprintf(":%s", ctx.String("port")), router.Init()); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|