2021-04-28 16:15:45 +02:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2022-03-06 16:54:19 +01:00
|
|
|
"github.com/rs/zerolog/log"
|
2021-04-28 16:15:45 +02:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2021-07-25 15:09:33 +02:00
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(serveCmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
var serveCmd = &cobra.Command{
|
2021-04-28 16:15:45 +02:00
|
|
|
Use: "serve",
|
|
|
|
Short: "Launches the headscale server",
|
|
|
|
Args: func(cmd *cobra.Command, args []string) error {
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2022-06-05 17:52:28 +02:00
|
|
|
app, err := getHeadscaleApp()
|
2021-04-28 16:15:45 +02:00
|
|
|
if err != nil {
|
2022-03-06 16:54:19 +01:00
|
|
|
log.Fatal().Caller().Err(err).Msg("Error initializing")
|
2021-04-28 16:15:45 +02:00
|
|
|
}
|
2021-08-12 21:44:12 +02:00
|
|
|
|
2022-06-05 17:52:28 +02:00
|
|
|
err = app.Serve()
|
2021-04-28 16:15:45 +02:00
|
|
|
if err != nil {
|
2022-03-06 16:54:19 +01:00
|
|
|
log.Fatal().Caller().Err(err).Msg("Error starting server")
|
2021-04-28 16:15:45 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|