How to continuously run "ipfs daemon" after terminating ssh session?

I got into learning Ubuntu thanks to running my own node. But when I run ipfs daemon, the process stops after I log off from my ssh session.

How do I keep it running?

And could I run it when my node server starts?

Google

linux add systemd service

And checkout go-ipfs/ipfs.service at master · ipfs/go-ipfs · GitHub

2 Likes

You’re a Godsend. Thanks a lot.

I found this and helped me all the way. But how do I stop the service? I tried running systemctl stop ipfs-daemon.service but it still runs (ipfs-daemon is my service file)

try ipfs shutdown
but my guess is that your .service file is wrong somehow (have you used the one that already exists in the go-ipfs repo ?).

I have no idea there’s one in go-ipfs repo. I’ll check it out.

it’s this link that I’ve sent you go-ipfs/ipfs.service at master · ipfs/go-ipfs · GitHub

Thanks so much. I did what you said by using go-ipfs/ipfs.service at master · ipfs/go-ipfs · GitHub but I changed a few variables as below.

User=ubuntu
ExecStart=/usr/bin/ipfs daemon

But I’m getting error below.


ipfs.service - InterPlanetary File System (IPFS) daemon
     Loaded: loaded (/etc/systemd/system/ipfs.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2022-05-06 03:41:10 UTC; 2min 19s ago
       Docs: https://docs.ipfs.io/
    Process: 5596 ExecStart=/usr/bin/ipfs daemon (code=exited, status=203/EXEC)
   Main PID: 5596 (code=exited, status=203/EXEC)

May 06 03:41:10 ip-172-31-20-222 systemd[1]: ipfs.service: Scheduled restart job, restart counter is at 5.
May 06 03:41:10 ip-172-31-20-222 systemd[1]: Stopped InterPlanetary File System (IPFS) daemon.
May 06 03:41:10 ip-172-31-20-222 systemd[1]: ipfs.service: Start request repeated too quickly.
May 06 03:41:10 ip-172-31-20-222 systemd[1]: ipfs.service: Failed with result 'exit-code'.
May 06 03:41:10 ip-172-31-20-222 systemd[1]: Failed to start InterPlanetary File System (IPFS) daemon.

So, I wonder, to fix the problem above, should the below be under [Unit] or [Service?

StartLimitBurst=5
StartLimitIntervalSec=10

And under [Service] I should add RestartSec=3

In reply to OP’s question, here is one solution…
Check the section under Adding the service on this page. A good tutorial here.

1 Like

The problem above is missleading.
The issue is not that IPFS is restarting too quickly, the issue is that IPFS fails in the first place.

Can you show more of the logs ? with journalctl -fu ipfs for example.

Link gone dead. Here is cached screenshot of deleted link page.


1 Like