Provide an easier way to programmatically start the daemon
- Dominant language
- Go
- Stars
- 17.1k
- Forks
- 3.2k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 11
Description
This is a continuation of https://github.com/ipfs/go-ipfs/issues/5983#issuecomment-463708585, since that's an old thread that was closed.
If one wants to execute `ipfs daemon` and wait for it to start, the only way right now is to run it and wait for `Daemon is ready` on stdout:
```
$ ipfs daemon
Initializing daemon...
go-ipfs version: 0.7.0-ea77213e3
Repo version: 10
System version: amd64/linux
Golang version: go1.15.2
Swarm listening on /ip4/127.0.0.1/tcp/4001
[...]
WebUI: http://127.0.0.1:5001/webui
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
```
This is what js-ipfsd-ctl does: https://github.com/ipfs/js-ipfsd-ctl/blob/master/src/ipfsd-daemon.js#L220
Note that I'm not interested in the Go APIs to run an IPFS node directly; I'm interested in executing the already-installed ipfs daemon from a separate program and any language.
I propose we add `ipfs daemon --fork`, which starts the daemon in a sub-process and returns when it's ready.
It would also be very useful to get information about the daemon that's been started, in a way that's easier for machines to parse. For example, the app starting the daemon is probably interested in fields above like `go-ipfs version` and `WebUI`, but the human-friendly output is not particularly consistent.
It would be great if, instead, you'd get something like:
```
$ ipfs daemon --fork
# we can print progress and errors here via stderr; json below is stdout
{
"version": "0.7.0-ea77213e3",
"repoVersion": "10",
"webUI": "http://127.0.0.1:5001/webui",
...
}
$ # daemon is now running
```
It's fine if the JSON output replacing the plaintext were behind another flag, like `--json`. I know that feature is somewhat separate from `--fork`, but I think the use case is extremely similar - gathering information from the started daemon without parsing the human-readable stdout lines.
cc @andrew @daviddias @olizilla @Stebalien
Contributor guide
Assessment
This issue has not been assessed yet.