Skip to content

Commit 6e82992

Browse files
committed
(cosmetic) reorganized runDaemonCommand in a more straighforward way
1 parent 5df98ee commit 6e82992

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Diff for: cli/daemon/daemon.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,28 @@ func NewCommand() *cobra.Command {
5050
}
5151

5252
func runDaemonCommand(cmd *cobra.Command, args []string) {
53-
lis, err := net.Listen("tcp", port)
54-
if err != nil {
55-
log.Fatalf("failed to listen: %v", err)
56-
}
5753
s := grpc.NewServer()
5854

59-
userAgentValue := fmt.Sprintf("%s/%s daemon (%s; %s; %s) Commit:%s", globals.VersionInfo.Application,
60-
globals.VersionInfo.VersionString, runtime.GOARCH, runtime.GOOS, runtime.Version(), globals.VersionInfo.Commit)
61-
headers := http.Header{"User-Agent": []string{userAgentValue}}
62-
6355
// register the commands service
64-
coreServer := daemon.ArduinoCoreServerImpl{
56+
headers := http.Header{"User-Agent": []string{
57+
fmt.Sprintf("%s/%s daemon (%s; %s; %s) Commit:%s",
58+
globals.VersionInfo.Application,
59+
globals.VersionInfo.VersionString,
60+
runtime.GOARCH, runtime.GOOS,
61+
runtime.Version(), globals.VersionInfo.Commit)}}
62+
srv_commands.RegisterArduinoCoreServer(s, &daemon.ArduinoCoreServerImpl{
6563
DownloaderHeaders: headers,
6664
VersionString: globals.VersionInfo.VersionString,
6765
Config: globals.Config,
68-
}
69-
srv_commands.RegisterArduinoCoreServer(s, &coreServer)
66+
})
7067

7168
// register the monitors service
7269
srv_monitor.RegisterMonitorServer(s, &daemon.MonitorService{})
7370

71+
lis, err := net.Listen("tcp", port)
72+
if err != nil {
73+
log.Fatalf("failed to listen: %v", err)
74+
}
7475
if err := s.Serve(lis); err != nil {
7576
log.Fatalf("failed to serve: %v", err)
7677
}

0 commit comments

Comments
 (0)