How do I undo the `ipfs daemon` command?

From @Mithgol on Tue Sep 15 2015 20:40:37 GMT+0000 (UTC)

How do I shot web terminate the unixweb daemon? Is there any ipfs daemon stop to undo ipfs daemon?


Copied from original issue: https://github.com/ipfs/faq/issues/39

From @lgierth on Tue Sep 15 2015 20:49:03 GMT+0000 (UTC)

You send it Ctrl-C to terminate gracefully, and a second Ctrl-C to terminate immediately.

From @jbenet on Tue Sep 15 2015 21:21:39 GMT+0000 (UTC)

@Mithgol or kill $pid or kill -9 $pid

From @jbenet on Tue Sep 15 2015 21:22:56 GMT+0000 (UTC)

(i suppose it may be convenient to have an ipfs daemon stop or something, for scripts and so on, but not 100% convinced yet).

From @Mithgol on Wed Sep 16 2015 06:41:04 GMT+0000 (UTC)

@jbenet Would you recommend taskkill /pid processID /f /t on Windows, or without /f, or without /t, or without both?

From @ligi on Thu Jun 02 2016 02:04:58 GMT+0000 (UTC)

+1 for ipfs daemon stop
use-case: I run the daemon via gomobile and there is no shell for kill commands or to send ctrl-c

From @jbenet on Sat Jun 04 2016 11:25:55 GMT+0000 (UTC)

After speaking with @ligi, it is clear that many applications will need to be able to trigger deamon to exit through the api.

i’d be in favor of a ipfs daemon stop

From @ligi on Sun Jun 05 2016 16:56:37 GMT+0000 (UTC)

that’s great - would also be great to have a way to query the status of the daemon ( z.b. inactive, initializing, initialized ) - currently e.g. the initializing state is hard to detect AFAIK

From @Kubuxu on Sun Jun 05 2016 17:17:53 GMT+0000 (UTC)

It is hard to detect as the peer discovery and inital connections run before API is started. There is very old issue about that: https://github.com/ipfs/go-ipfs/issues/973

Which means that you can’t query daemon information until it started.

The ipfs daemon stop could be created by creating pid file inside a repo structure, it wouldn’t be that hard to do.

Then, IMO, we should provided build in daemonisation of the daemon (forking mode).

From @snow-frog on Fri Mar 24 2017 05:48:19 GMT+0000 (UTC)

Seriously, we don’t have this yet? Come on…

From @alexgarciac on Tue Mar 28 2017 22:24:03 GMT+0000 (UTC)

Seriously needed… ipfs daemon stop

From @whyrusleeping on Tue Mar 28 2017 23:00:22 GMT+0000 (UTC)

There are quite a bit of other things that have taken priority, I’ll try and get this prioritized soon. That said, we do accept PRs :wink:

From @hsanjuan on Wed Mar 29 2017 12:31:56 GMT+0000 (UTC)

Unless you are in a situation like ligi describes (exec-ing the daemon inside an Android app), there are multiple workarounds for this. One is using a systemd service as shown at https://github.com/ipfs/examples/tree/master/examples/init to start/stop ipfs, which will additionally also collect your logs.

From @snow-frog on Thu Mar 30 2017 09:20:38 GMT+0000 (UTC)

…and on windows?

From @hsanjuan on Thu Mar 30 2017 09:39:58 GMT+0000 (UTC)

I don’t use windows, but http://tweaks.com/windows/39559/kill-processes-from-command-prompt/ says you can do something like taskkill /IM ipfs. There are shell aliases or you can put it in a script called ipfsstop.cmd.

That said, I don’t know if exit is handled correctly in this case or ipfs will be killed immediately. Can you test?

From @noxonsu on Sat Apr 08 2017 16:08:06 GMT+0000 (UTC)

taskkill /IM ipfs.exe /f

this work for me. But what about /Users/…/repo.lock file? How to “unlock” him? I try this, but not working

function getUserHome() {
 return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
}

if (fs.existsSync(getUserHome()+"/.ipfs/repo.lock")) {
fs.unlink(getUserHome()+"/.ipfs/repo.lock");
}