-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Provide an easier way to programmatically start the daemon #7895
Comments
One more thought - the forking does complicate controlling the process in a programmatic way. Right now, I can simply use https://golang.org/pkg/os/exec/#Cmd.Wait to notice when the daemon exits or crashes. If this new flag forks, then One possible way would be for the JSON to provide a PID as well, and then it's up to the caller to wait on that PID if they wish. Another possible way would be to not fork. The caller would wait for a JSON object to be printed to stdout, meaning that the daemon has started, and then wait for the process to finish to notice when the daemon exits. This is sort of similar to what we have right now, but the JSON would be properly documented and easier to parse, as opposed to the plaintext stdout lines we have right now. I think I prefer the latter, since it feels more powerful overall. But the former would be easier to use directly from the command line. |
I'm a big +1 on having a command that lets us start the daemon and exits when it's ready... people shouldn't need to write stuff like this https://github.com/alexanderschau/ipfs-pinning-action/blob/main/waitForIpfs.go If forking creates complications, we could add a seperate command like |
For what it's worth I needed something similar recently. And quickly hacked together this |
For the time-being, I am using this one-liner to start the daemon in background and wait until it's ready.
Outputs something when Daemon is ready, nothing otherwise. |
Seems like a big chunk of this use case could be satisfied with a Lotus-like tool to tell when the API is receiving requests (independent of which process is servicing it, maybe the current As an extra we can better structure daemon output as JSON provided the user clearly understand that the (Alternatively we could merge the two above and monitor the server within the daemon command itself to print/emit/run callback when the server is accepting requests.) Way down on my priority list would be baking some forking procedure into cc @aschmahmann for feedback on this to get a scoped useful first step toward making this pain point better (won't move on this until confirmation) |
This is a continuation of #5983 (comment), 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 forDaemon is ready
on stdout: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
andWebUI
, but the human-friendly output is not particularly consistent.It would be great if, instead, you'd get something like:
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
The text was updated successfully, but these errors were encountered: