Skip to content
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

daemon: add options to set the API and GW addresses #845

Closed
wants to merge 2 commits into from

Conversation

BenoitKnecht
Copy link

The ipfs daemon command lets you initialize the configuration with
default parameters, but in certain situations (like starting ipfs daemon
in a docker container), it would be convenient to be able to set the
API and gateway addresses to something more meaningful.

This patch introduces two new options for the ipfs daemon command:
-address-api and -address-gateway. When used together with -init, they
set the respective addresses in the generated configuration file:

$ ipfs daemon -init -address-api=/ip4/0.0.0.0/tcp/5001
-address-gateway=/ip4/0.0.0.0/tcp/8080

When used without -init, they simply override value for that run of the
daemon, without overwriting it in the configuration file:

$ ipfs daemon -address-api=/ip4/0.0.0.0/tcp/5001
-address-gateway=/ip4/0.0.0.0/tcp/8080

The ipfs daemon command lets you initialize the configuration with
default parameters, but in certain situations (like starting ipfs daemon
in a docker container), it would be convenient to be able to set the
API and gateway addresses to something more meaningful.

This patch introduces two new options for the ipfs daemon command:
-address-api and -address-gateway. When used together with -init, they
set the respective addresses in the generated configuration file:

  $ ipfs daemon -init -address-api=/ip4/0.0.0.0/tcp/5001 \
  -address-gateway=/ip4/0.0.0.0/tcp/8080

When used without -init, they simply override value for that run of the
daemon, without overwriting it in the configuration file:

  $ ipfs daemon -address-api=/ip4/0.0.0.0/tcp/5001 \
  -address-gateway=/ip4/0.0.0.0/tcp/8080
@Luzifer
Copy link
Member

Luzifer commented Mar 2, 2015

Intention ❤️

@whyrusleeping
Copy link
Member

Would be neat to generalize this into something like:

$ ipfs daemon -conf="Addresses.API=/ip4/0.0.0.0/tcp/5002"

Although that might be difficult/confusing

Commit 8bdf7f6 introduced and extra argument to config.Init, but failed
to add it to all calls of config.Init. This should take care of all of
them.
@BenoitKnecht
Copy link
Author

Sorry about the breakage, it should work now.

@whyrusleeping I agree it would be nice to have something more generic, but as you say, it would be more complicated to implement.

@whyrusleeping
Copy link
Member

Yeah, this LGTM. It solves the problem at hand.

@jbenet
Copy link
Member

jbenet commented Mar 3, 2015

I'd prefer if we generalized sooner than later. when we change, it will break people's scripts.

  • How about --config="<key>=<val>" as @whyrusleeping suggests?
  • And/or, allow passing a partial config via stdin to ipfs daemon --init? (some values are json arrays)
  • And/or, allow overriding with env vars.

see also: #387 #251 http://github.com/spf13/viper

@BenoitKnecht
Copy link
Author

@jbenet Okay, but then it should also be unified between daemon, init and config, as they all offer different ways to alter the configuration file. I'll try and take a look at it over the week-end, and see if I can come up with something.

If anyone has suggestions, or wants to help me on this, don't hesitate.

@chriscool
Copy link
Contributor

git has a '-c' option that can be used to change some config parameters when launching a command. No config file is changed. Config options passed like this only have effects on the current command. This option can be used with any command but must me put between 'git' and the command name on the command line.

For example git -c "color.ui=false" log will show the output of the log command without color, but will not change any default.

@jbenet
Copy link
Member

jbenet commented Mar 6, 2015

thanks @chriscool -- i like it. agreed that it should only be for that run-- no change to the config on disk.

Perhaps we should repurpose our own -c to do this too, and switch its current use of -c (changing the IPFS_PATH) to --ipfs-path.

@jbenet
Copy link
Member

jbenet commented Apr 10, 2015

@BenoitKnecht thoughts on this?

@whyrusleeping
Copy link
Member

closing due to inactivity, please reopen as necessary

note: all pull requests older than three weeks may be closed in an effort to keep our open pull requests more focused.

@Arlodotexe
Copy link

Arlodotexe commented Feb 28, 2023

I would like to see this feature added. I'm building dotnet tooling to bootstrap and start the Kubo process, and would like to provide the option to change this before first startup. This would greatly simplify the setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants