mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-02 07:06:41 +00:00
Extend the cmd with argument handling
- add cobra to relay server - add logger instance for handshaker
This commit is contained in:
@@ -6,13 +6,27 @@ import (
|
||||
"syscall"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/netbirdio/netbird/relay/server"
|
||||
"github.com/netbirdio/netbird/util"
|
||||
)
|
||||
|
||||
var (
|
||||
listenAddress string
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "relay",
|
||||
Short: "Relay service",
|
||||
Long: "Relay service for Netbird agents",
|
||||
Run: execute,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
util.InitLog("trace", "console")
|
||||
_ = util.InitLog("trace", "console")
|
||||
rootCmd.PersistentFlags().StringVarP(&listenAddress, "listen-address", "l", ":1235", "listen address")
|
||||
|
||||
}
|
||||
|
||||
func waitForExitSignal() {
|
||||
@@ -21,10 +35,9 @@ func waitForExitSignal() {
|
||||
_ = <-osSigs
|
||||
}
|
||||
|
||||
func main() {
|
||||
address := "10.145.236.1:1235"
|
||||
func execute(cmd *cobra.Command, args []string) {
|
||||
srv := server.NewServer()
|
||||
err := srv.Listen(address)
|
||||
err := srv.Listen(listenAddress)
|
||||
if err != nil {
|
||||
log.Errorf("failed to bind server: %s", err)
|
||||
os.Exit(1)
|
||||
@@ -38,3 +51,10 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user