Skip to content

IDE to run CLI with auto assigned port #673

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

Merged
merged 6 commits into from
Dec 9, 2021
Merged

IDE to run CLI with auto assigned port #673

merged 6 commits into from
Dec 9, 2021

Conversation

fstasi
Copy link
Contributor

@fstasi fstasi commented Dec 9, 2021

Why

It's not possible to make assumptions on what ports are available on the different OS the IDE can be run, and the default port 50051 is already in use in some cases (such as OS Monterey).
This issue is particularly annoying for first-time users that should go into the CLI configuration and change the port manually, before running the IDE.

How

The IDE now force the CLI daemon port to 0 (automatically assigned from the OS). This ensure an available port is always picked up and the IDE can start normally, without manual intervention of the user

Comment on lines 117 to 123
const { daemon, port } = await new SilentArduinoDaemonImpl(
'json'
).spawnDaemonProcess();
expect(instance.port).not.to.be.undefined;
expect(instance.port).not.to.be.equal('0');

expect(port).not.to.be.undefined;
expect(port).not.to.be.equal('0');
daemon.kill();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'd prefer to put the new SilentArduinoDaemonImpl('json').spawnDaemonProcess(); in the beforeEach and the daemon.kill() in the afterEach.
@fstasi does it make sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we actually run the SilentArduinoDaemonImpl with different input: json or text.. we can make a wrapper function probably

@fstasi fstasi merged commit 49d12d9 into main Dec 9, 2021
@fstasi fstasi deleted the read-cli-port branch December 9, 2021 14:08
@per1234 per1234 added topic: CLI Related to Arduino CLI topic: code Related to content of the project itself type: enhancement Proposed improvement labels Dec 9, 2021
@per1234 per1234 linked an issue Dec 11, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to Arduino CLI topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
4 participants