Skip to content

Separate settings exclusive to daemon mode from other settings #1620

Closed
@silvanocerza

Description

@silvanocerza

Currently there is a central place where all settings are stored, the arduino-cli.yaml file. It usually looks something like this:

board_manager:
  additional_urls:
  - https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  - http://arduino.esp8266.com/stable/package_esp8266com_index.json
daemon:
  port: "50051"
directories:
  data: /home/alien/.arduino15
  downloads: /home/alien/.arduino15/staging
  user: /home/alien/Arduino
library:
  enable_unsafe_install: false
logging:
  file: ""
  format: text
  level: info
metrics:
  addr: :9090
  enabled: true
output:
  no_color: false
sketch:
  always_export_binaries: false
updater:
  enable_notification: true

This file stores settings that are needed by the Arduino CLI when running as a daemon and when running as a command line tool.

When running in daemon mode the gRPC consumers connected to it can create multiple internal instances but the settings are shared between them, so we can't have different clients with different settings connected to the same daemon process because if one of the client edits the settings it would change for everyone connected.

We could solve the above problem by storing the settings in the internal CoreInstance created by the gRPC clients, but that causes also some other issues. What would happen if a client connects to the daemon and changes the port used by the daemon? It would break the connection for all clients the next time the daemon is restarted, so it must not be possible for the gRPC clients to change that. What about logging? Why should the clients be able to change the daemon settings if they might not even be tasked with running it?

When running the Arduino CLI as a normal command line tool we create a single internal instance, so we can treat it similarly as a gRPC client. Though when running as a command line tool we might need logging too, as much as when we run it in daemon mode.

Given the above information we must separate some settings from the essential ones, see daemon config, and some other settings instead must be duplicated both for daemon mode and command line mode, see metrics and logging configs.

This change is necessary to move the settings inside the CoreInstance.
If we'd move the settings inside the instance before separating the daemon settings from the other ones we wouldn't be able to run the daemon with the correct settings, since we'd have first to create an instance to be able to access them.

Metadata

Metadata

Assignees

Labels

conclusion: resolvedIssue was resolvedtopic: CLIRelated to the command line interfacetopic: codeRelated to content of the project itselftopic: gRPCRelated to the gRPC interfacetype: enhancementProposed improvement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions