Skip to content

Separate settings exclusive to daemon mode from other settings #1620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
silvanocerza opened this issue Jan 10, 2022 · 0 comments · Fixed by #1622
Closed

Separate settings exclusive to daemon mode from other settings #1620

silvanocerza opened this issue Jan 10, 2022 · 0 comments · Fixed by #1622
Assignees
Labels
conclusion: resolved Issue was resolved topic: CLI Related to the command line interface topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement

Comments

@silvanocerza
Copy link
Contributor

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.

@silvanocerza silvanocerza added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: CLI Related to the command line interface topic: gRPC Related to the gRPC interface labels Jan 10, 2022
@silvanocerza silvanocerza self-assigned this Jan 10, 2022
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: CLI Related to the command line interface topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants