Restarting ipfs after reboots and logouts (Linux systemd issues)

Hi,

I’ve been trying to get an IPFS node running 24/7 on my Raspberry PI with Fedora.

Installation went fine and everything seems to be running correctly with

$ systemctl --user enable ipfs.service
$ systemctl --user start ipfs.service

Of course it stops the service when I log out, as per user instance behaviour for systemd. I tried invoking it as a system instance with a defined user, and ran into a series of SELinux issues I can’t even begin to understand, let alone resolve. So, I went back to a systemd user instance and (not happily) ran “loginctl enable-linger craig”

Now ipfs remains running when I log out, however it doesn’t restart on reboot. After rebooting, the status shows:

$ systemctl --user status ipfs.service
○ ipfs.service - IPFS Daemon
     Loaded: loaded (/home/craig/.config/systemd/user/ipfs.service; enabled; vendor preset: disabled)
     Active: inactive (dead)

And weirdly, I can’t find anything from ipfs in journalctl timestamped after the reboot ( Oh, how I miss /var/log/messages and UNIX text tools :slight_smile: )

Does anybody know how to get this working?

My ipfs.service file is as follows:

[Unit]
Description=IPFS Daemon
After=network.target

[Service]
#TimeoutStartSec=infinity
#Type=notify
#User=craig
#Group=craig

#StateDirectory=craig
#Environment=IPFS_PATH="${HOME}"

ExecStart=/usr/local/bin/ipfs daemon
Restart=on-failure
#KillSignal=SIGINT

[Install]
WantedBy=multi-user.target
1 Like

Following up …

The best I was able to do for now was to create the following script (ipfs_alive)

#!/bin/bash

while true
do
    sleep 60
    STATE=`systemctl --user is-active ipfs.service`
    if [ $STATE == 'inactive' ]; then
        systemctl --user start ipfs.service
    fi
done

and then modify my crontab with “crontab -e”

PATH="/home/craig/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin"

@reboot ipfs_alive

This functions, but doesn’t seem ideal.