Description
Describe the problem
Pluggable discovery tools supply Arduino CLI with a list of "ports" of connected Arduino boards. When Arduino CLI is running as a daemon, these tools are started when a gRPC request is received that requires a port listing and then left running for the remainder of the session.
🐛 Redundant processes for each discovery tool are created by additional instances of the Arduino CLI daemon. It is possible that discovery tools may not be designed to operate correctly in this way, and the multiple processes might interfere with each other.
To reproduce
Setup
$ arduino-cli version
arduino-cli Version: 0.29.0-rc.1 Commit: 76251df9 Date: 2022-11-17T03:35:12Z
$ arduino-cli daemon
Daemon is now listening on 127.0.0.1:50051
Demo
run the following grpcurl
commands in another terminal:
$ grpcurl \
-plaintext \
-import-path ./rpc \
-proto cc/arduino/cli/commands/v1/commands.proto \
127.0.0.1:50051 \
cc.arduino.cli.commands.v1.ArduinoCoreService.Create
{
"instance": {
"id": 1
}
}
$ grpcurl \
-plaintext \
-import-path ./rpc \
-proto cc/arduino/cli/commands/v1/commands.proto \
-d '{"instance": {"id": 1}}' \
127.0.0.1:50051 \
cc.arduino.cli.commands.v1.ArduinoCoreService.Init
$ pgrep -a -f 'serial-discovery' # Discovery tools have not yet been started
$ grpcurl \
-plaintext \
-import-path ./rpc \
-proto cc/arduino/cli/commands/v1/commands.proto \
-d '{"instance": {"id": 1}}' \
127.0.0.1:50051 \
cc.arduino.cli.commands.v1.ArduinoCoreService.BoardList
[...]
$ pgrep -a -f 'serial-discovery' # A process for each discovery tool was created
134825 /home/per/.arduino15/packages/builtin/tools/serial-discovery/1.3.2/serial-discovery
$ grpcurl \
-plaintext \
-import-path ./rpc \
-proto cc/arduino/cli/commands/v1/commands.proto \
127.0.0.1:50051 \
cc.arduino.cli.commands.v1.ArduinoCoreService.Create
{
"instance": {
"id": 2
}
}
$ grpcurl \
-plaintext \
-import-path ./rpc \
-proto cc/arduino/cli/commands/v1/commands.proto \
-d '{"instance": {"id": 2}}' \
127.0.0.1:50051 \
cc.arduino.cli.commands.v1.ArduinoCoreService.Init
$ grpcurl \
-plaintext \
-import-path ./rpc \
-proto cc/arduino/cli/commands/v1/commands.proto \
-d '{"instance": {"id": 2}}' \
127.0.0.1:50051 \
cc.arduino.cli.commands.v1.ArduinoCoreService.BoardList
[...]
$ pgrep -a -f 'serial-discovery'
134825 /home/per/.arduino15/packages/builtin/tools/serial-discovery/1.3.2/serial-discovery
135007 /home/per/.arduino15/packages/builtin/tools/serial-discovery/1.3.2/serial-discovery
🐛 A new process is created for each discovery tool by additional Arduino CLI daemon instances.
Expected behavior
A single instance of each discovery tool should be shared by all Arduino CLI daemon instances.
Arduino CLI version
Operating system
Windows, Ubuntu
Operating system version
Windows 10, Ubuntu 20.04
Additional context
Related: #1960
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the nightly build
- My report contains all necessary details