Best way to keep daemon running

I have explicit need to have ipfs daemon running all the time on OS X. Specifically I need to be ablt to access http api on 127.0.0.1:5001

For this I have included ipfs dist and LaunchAgent plist into installation, but I have encountered few issues:

  1. Explicit need to init the daemon before running it makes it harder for OS to keep track of the process since I’m forced to use script in which ipfs init && ipfs daemon are scripted. I can’t just feed launch agent the ‘ipfs daemon’ because it will fail if not init-ed. How to avoid it?
  2. After some time users have problems accessing http api because ipfs requres explicit permission to escalate DB version which cannot be done (as I run launchagent as root) by user and he doesn’t know about it. process fails on start

In general: what’s the best way to keep daemon alive (maybe use js version?), I just need persistent access to http api and users don’t care that daemon is failing, they only see my program not working and they won’t manage ipfs themselves

  1. You can start the daemon with --init, that way IPFS would run ipfs init for you, if necessary.

  2. The repo won’t update by itself, only when you run ipfs init with a new repository version OR when using https://github.com/ipfs/fs-repo-migrations. If you keep using the same IPFS version, the repository will continue to work with that version.

I guess you could add some utility command that would compare a new IPFS version with the current one, and run fs-repo-migrations if different, then download and install the new version.

Thanks! That helps.

Another question: is there a good way to install IPFS as a service on Windows? I tried to do it, but IPFS doesn’t release launch frame when started (not return value), thus making windows believe service is still starting up. It waits for it for like 2 minutes and terminates as failure. Is there any workaround?

No worries :slight_smile:

Now I’m no windows expert, but I’ve always used NSSM for setting up services on Windows, most of them launched by a forever-running command.

You would basically have to do this to have IPFS as a service on Windows with NSSM:

nssm install ipfs ipfs daemon --init

And then you can either start the service via the GUI or run nssm start ipfs and it should have been launched. YMMV

You can find NSSM here: https://nssm.cc/

Thanks a lot! I’ll try it out

When i start it using “nssm ipfs start” (need to start it as Administrator), my files was missing in localhost:5001 / Files page
But when i start it using “ipfs daemon --init” my files are back there in
localhost:5001 / Files page

i installed nssm service using advised command “nssm install ipfs ipfs daemon --init”, i hope i did it via Administrator command window. Not sure what is the problem, why files are different/missing. :-/

By the way, here is advised other method to run ipfs on background as a daemon: https://github.com/ipfs/go-ipfs/issues/3572#issuecomment-275590096