ipfs-shipyard / go-ipfs-desktop

Other
12 stars 6 forks source link

track if the ipfs daemon is running or not #3

Closed mvdan closed 3 years ago

mvdan commented 3 years ago

For example, if it crashes or if the user stops it.

The simplest way would be to periodically check that it's still running after we start it.

A better way would be to remain connected to the IPFS daemon in some way (via a socket, or an API endpoint) and then notice when the connection drops because the daemon is killed.

Should we also notice if the ipfs daemon is started by the user? Probably not, because this tool is not aimed at power users who would start the IPFS daemon directly.

mvdan commented 3 years ago

From @lidel, a way to inspect if there's a local node currently running:

1) check if $IPFS_PATH/api exists 2) see if $IPFS_PATH/config exists 3) if both exist, read Identity.PeerID from config and then connect to the address from api and do HTTP POST /api/v0/id and see if ID is the same as PeerID from config. If they match, then you know its the local node running

This is because some people manually create the api file to point to a remote node, to use ipfs as a CLI against a remote node.

The above is only really helpful if we want to support the case where the user manually started ipfs daemon, and then started the systray app. Arguably that's not a super important use case, since this systray app is not for power users.

--

I think the above is probably overcomplicating things. This systray app is not for power users, so we should not support the user messing with the daemon directly. We start the process, so we simply Wait() on it to notice when it dies for whatever reason.

lidel commented 3 years ago

Arguably that's not a super important use case, since this systray app is not for power users.

I was thinking the same, but turns some of our issue-filling-IPFS-Desktop-users are running their node either in Docker or separate machine in LAN / VPN :trollface:

But I agree, for MVP ignoring manually created api is good enough.

mvdan commented 3 years ago

Wait, people who manually mess with the IPFS directory to not run a local node, also want a pretty systray to track said remote node? It makes little sense to me :P