bacalhau-project / bacalhau

Compute over Data framework for public, transparent, and optionally verifiable computation
https://docs.bacalhau.org
Apache License 2.0
675 stars 88 forks source link

issue with -c api.port #4539

Open wdbaruni opened 4 days ago

wdbaruni commented 4 days ago

Having a space between api.port and the value causes the port to be read as 1

→ bacalhau serve --orchestrator  -c orchestrator.port 2222 -c api.port=3333
16:34:09.008 | INF ../ProtocolLabs/workspace/bacalhau/cmd/cli/serve/serve.go:102 > Config loaded from: [], and with data-dir /var/folders/vz/pk7pk9qx1c5gbktg8nhyl88h0000gn/T/bacalhau_test.AjhLLURDzE
16:34:09.018 | INF ../ProtocolLabs/workspace/bacalhau/cmd/cli/serve/serve.go:228 > Starting bacalhau...
16:34:09.054 | INF ../ProtocolLabs/workspace/bacalhau/cmd/cli/serve/serve.go:299 > bacalhau node running [address:0.0.0.0:3333] [compute_enabled:false] [name:n-ed0ddc0f-40af-4ce5-8c24-6d6d39649321] [orchestrator_address:0.0.0.0:1] [orchestrator_enabled:true] [webui_enabled:false]

To connect to this node from the local client, run the following commands in your shell:
export BACALHAU_API_HOST=127.0.0.1
export BACALHAU_API_PORT=3333

→ bacalhau serve --orchestrator  -c orchestrator.port 2222 -c api.port 3333
16:34:21.781 | INF ../ProtocolLabs/workspace/bacalhau/cmd/cli/serve/serve.go:102 > Config loaded from: [], and with data-dir /var/folders/vz/pk7pk9qx1c5gbktg8nhyl88h0000gn/T/bacalhau_test.AjhLLURDzE
16:34:21.799 | INF ../ProtocolLabs/workspace/bacalhau/cmd/cli/serve/serve.go:228 > Starting bacalhau...

Error: address http://0.0.0.0:1 is already in use
Hint:  To resolve this, either:
1. Check if you are already running bacalhau
2. Stop the other process using the port
3. Configure a different port using one of these methods:
   a. Use the `-c api.port=<new_port>` flag with your serve command
   b. Set the port in a configuration file with `bacalhau config set api.port=<new_port>`
frrist commented 4 days ago

Yeah we can't have spaces with the -c/--config flag.
bacalhau serve --orchestrator -c orchestrator.port=2222 -c api.port=3333 is the correct command. This is because flags accept a single argument. We discussed this trade-off in https://github.com/bacalhau-project/bacalhau/pull/4242 and several meetings.

frrist commented 4 days ago

One actionable item from this issue is improving the help text of the flag to make this clearer Currently, it states:

  -c, --config string     config file(s) or dot separated path(s) to config values

And the below would be more informative:

  -c, --config string     Specify one or more configuration files or inline configuration values.

                          - To use a YAML file, provide the file path:
                              --config <file_path>

                          - To set individual key-value pairs, use dot-separated paths:
                              --config <config_key>=<value>

                          - For map values, separate key-value pairs with commas:
                              --config <config_key>=<key1>=<value1>,<key2>=<value2>

                          - For array values, provide a comma-separated list:
                              --config <config_key>=<value1>,<value2>,...,<valueN>