-
-
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
How to tell if succeede to start ipfs daemon ? #5983
Comments
The standard way is to check the daemon Keep in mind that this isn't a 100% safe method as the file may remain there after, say, a crash (see #5784). I'm going to close this issue for tracking purposes since it seems like it's something that should be discussed in our forum https://discuss.ipfs.io (although this could actually be reformatted as a documentation issue, since this |
Thanks @schomatis - though as you say, it probably should be documented since its so different from how IPFS does everything else. Also ... I guess its a bug that if you run If I've got this right the process is something like this .... which is pretty counterintuitive so at very least probably needs documenting somewhere.
|
That's the issue I was pointing you to, see #5784. Using
and in that case the process doesn't get the chance to do anything else (like cleaning the
As a secondary measure you can also check if the daemon API port is open (to which the commands connect to), it's the one reported in the initial log as,
It is set to a random port by default (in that case you'd need to parse this output) but you can just set it to a fixed value in Also, we can just offload this to any command that needs the daemon to run, e.g.,
This command works only with a daemon running and I think it will fail otherwise (check this please), that is, we have an Duplicate of #862.
Documentation PRs are always welcomed 😄 |
Understood re Ctrl-C; Ctlr-C, my mistake - I misread it as one of those messages that was really asking "Are you sure", rather than "I've started the process, another ctrl-c will hurry it up!". Correct A "Documentation PR" requires By the way ....I'll use that shell sequence for now, but I think a supported command whose behavior was .
Or maybe Just a suggestion - I don't know golang so can't really be of use there. |
So... the most correct way to do this is to wait for the string "Daemon is ready" on stdout. But yeah, some kind of |
Is anyone able to share a code example of how to wait until the IPFS daemon is running? I have tried to write a script based on waiting until |
Or you can try whether the id interface has the correct return value or exception
|
I've further developed the idea from #5983 (comment) in a new issue, if anyone here wants to follow it. |
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. To reflect daemon launch success in exit code, simply modify it as:
|
it will launch your command only after daemon is ready: ipfs daemon 2>&1 | grep -i -o -m1 "Daemon is ready" | xargs -i <your_any_command> |
Version information:
go-ipfs version: 0.4.18-
Repo version: 7
System version: amd64/darwin
Golang version: go1.11.1
Type:
enhancement
Description:
I'm trying to ensure that the IPFS daemon is running when starting a server that will use it, so something like what you'd logically think from .... :
There are two problems with this ... firstly that running
ipfs daemon &
is always going to return 0, and secondlyipfs daemon
fails in either the case that ipfs doesnt exist OR that its already running.And
ipfs --version
returns a version whether the daemon is running or not so I can't use that.What I'd like to figure out is how to do two things - either at the same time, or in two steps.
1: Start ipfs if its not already running.
2: Tell (in a shell script) whether IPFS daemon started.
Am I missing this in the docs and in
ipfs daemon --help
, or is this an enhancement request ?The text was updated successfully, but these errors were encountered: