netbird/client/cmd/service.go

46 lines
995 B
Go
Raw Permalink Normal View History

2021-06-19 14:55:45 +02:00
package cmd
import (
"context"
2021-06-19 14:55:45 +02:00
"github.com/kardianos/service"
log "github.com/sirupsen/logrus"
2021-06-19 14:55:45 +02:00
"github.com/spf13/cobra"
"google.golang.org/grpc"
"github.com/netbirdio/netbird/client/internal"
2021-06-19 14:55:45 +02:00
)
type program struct {
ctx context.Context
cancel context.CancelFunc
serv *grpc.Server
}
func newProgram(ctx context.Context, cancel context.CancelFunc) *program {
ctx = internal.CtxInitState(ctx)
return &program{ctx: ctx, cancel: cancel}
}
2021-06-19 14:55:45 +02:00
func newSVCConfig() *service.Config {
return &service.Config{
Name: serviceName,
2022-05-22 18:53:47 +02:00
DisplayName: "Netbird",
Description: "A WireGuard-based mesh network that connects your devices into a single private network.",
Option: make(service.KeyValue),
2021-06-19 14:55:45 +02:00
}
}
func newSVC(prg *program, conf *service.Config) (service.Service, error) {
s, err := service.New(prg, conf)
if err != nil {
log.Fatal(err)
return nil, err
}
return s, nil
}
var serviceCmd = &cobra.Command{
Use: "service",
2022-05-22 18:53:47 +02:00
Short: "manages Netbird service",
}