@@ -34,16 +34,14 @@ import (
34
34
"google.golang.org/grpc"
35
35
)
36
36
37
-
var (
38
-
daemonize bool
39
-
debug bool
40
-
debugFile string
41
-
debugFilters []string
42
-
)
43
-
44
37
// NewCommand created a new `daemon` command
45
38
func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *cobra.Command {
39
+
var daemonize bool
40
+
var debug bool
41
+
var debugFile string
42
+
var debugFiltersArg []string
46
43
var daemonPort string
44
+
var maxGRPCRecvMsgSize int
47
45
daemonCommand := &cobra.Command{
48
46
Use: "daemon",
49
47
Short: i18n.Tr("Run the Arduino CLI as a gRPC daemon."),
@@ -63,9 +61,14 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
63
61
panic("Failed to set default value for directories.builtin.libraries: " + err.Error())
64
62
}
65
63
}
64
+
65
+
// Validate the maxGRPCRecvMsgSize flag
66
+
if maxGRPCRecvMsgSize < 1024 {
67
+
feedback.Fatal(i18n.Tr("%s must be >= 1024", "--max-grpc-recv-message-size"), feedback.ErrBadArgument)
68
+
}
66
69
},
67
70
Run: func(cmd *cobra.Command, args []string) {
68
-
runDaemonCommand(srv, daemonPort)
71
+
runDaemonCommand(srv, daemonPort, debugFile, debug, daemonize, debugFiltersArg, maxGRPCRecvMsgSize)
69
72
},
70
73
}
71
74
defaultDaemonPort := settings.GetDaemon().GetPort()
@@ -82,13 +85,16 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
82
85
daemonCommand.Flags().StringVar(&debugFile,
83
86
"debug-file", "",
84
87
i18n.Tr("Append debug logging to the specified file"))
85
-
daemonCommand.Flags().StringSliceVar(&debugFilters,
88
+
daemonCommand.Flags().StringSliceVar(&debugFiltersArg,
86
89
"debug-filter", []string{},
87
90
i18n.Tr("Display only the provided gRPC calls"))
91
+
daemonCommand.Flags().IntVar(&maxGRPCRecvMsgSize,
92
+
"max-grpc-recv-message-size", 16*1024*1024,
93
+
i18n.Tr("Sets the maximum message size in bytes the daemon can receive"))
88
94
return daemonCommand
89
95
}
90
96
91
-
func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort string) {
97
+
func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort, debugFile string, debug, daemonize bool, debugFiltersArg []string, maxGRPCRecvMsgSize int) {
92
98
logrus.Info("Executing `arduino-cli daemon`")
93
99
94
100
gRPCOptions := []grpc.ServerOption{}
@@ -113,11 +119,13 @@ func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort string) {
113
119
debugStdOut = out
114
120
}
115
121
}
122
+
debugFilters = debugFiltersArg
116
123
gRPCOptions = append(gRPCOptions,
117
124
grpc.UnaryInterceptor(unaryLoggerInterceptor),
118
125
grpc.StreamInterceptor(streamLoggerInterceptor),
119
126
)
120
127
}
128
+
gRPCOptions = append(gRPCOptions, grpc.MaxRecvMsgSize(maxGRPCRecvMsgSize))
121
129
s := grpc.NewServer(gRPCOptions...)
122
130
123
131
// register the commands service
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4