1
0
mirror of https://github.com/juanfont/headscale.git synced 2024-12-20 19:09:07 +01:00
juanfont.headscale/cmd/headscale/cli/serve.go

33 lines
665 B
Go
Raw Permalink Normal View History

package cli
import (
"errors"
"net/http"
2022-03-06 16:54:19 +01:00
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
2021-07-25 15:09:33 +02:00
func init() {
rootCmd.AddCommand(serveCmd)
}
var serveCmd = &cobra.Command{
Use: "serve",
Short: "Launches the headscale server",
Args: func(cmd *cobra.Command, args []string) error {
return nil
},
Run: func(cmd *cobra.Command, args []string) {
app, err := newHeadscaleServerWithConfig()
if err != nil {
2022-03-06 16:54:19 +01:00
log.Fatal().Caller().Err(err).Msg("Error initializing")
}
2022-06-05 17:52:28 +02:00
err = app.Serve()
if err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Fatal().Caller().Err(err).Msg("Headscale ran into an error and had to shut down.")
}
},
}