1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-28 11:14:43 +00:00
steve/main.go

44 lines
963 B
Go
Raw Normal View History

2019-08-04 17:41:32 +00:00
package main
import (
"os"
"github.com/rancher/dynamiclistener/server"
2020-01-31 05:37:59 +00:00
"github.com/rancher/steve/pkg/debug"
stevecli "github.com/rancher/steve/pkg/server/cli"
2019-09-11 21:05:00 +00:00
"github.com/rancher/steve/pkg/version"
"github.com/rancher/wrangler/v3/pkg/signals"
2019-08-04 17:41:32 +00:00
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var (
2020-01-31 05:37:59 +00:00
config stevecli.Config
debugconfig debug.Config
2019-08-04 17:41:32 +00:00
)
func main() {
app := cli.NewApp()
2019-09-11 21:05:00 +00:00
app.Name = "steve"
2019-08-04 17:41:32 +00:00
app.Version = version.FriendlyVersion()
app.Usage = ""
2020-01-31 05:37:59 +00:00
app.Flags = append(
stevecli.Flags(&config),
debug.Flags(&debugconfig)...)
2019-08-04 17:41:32 +00:00
app.Action = run
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}
2020-01-31 05:37:59 +00:00
func run(_ *cli.Context) error {
2022-01-07 21:29:46 +00:00
ctx := signals.SetupSignalContext()
2020-01-31 05:37:59 +00:00
debugconfig.MustSetupDebug()
s, err := config.ToServer(ctx, debugconfig.SQLCache)
if err != nil {
return err
}
return s.ListenAndServe(ctx, config.HTTPSListenPort, config.HTTPListenPort, &server.ListenOpts{DisplayServerLogs: true})
2019-08-04 17:41:32 +00:00
}