go-ipfs can be started by your operating system's native init system.
For systemd
, the best approach is to run the daemon in a user session. Here is a sample service file:
[Unit]
Description=IPFS daemon
[Service]
# Environment="IPFS_PATH=/data/ipfs" # optional path to ipfs init directory if not default ($HOME/.ipfs)
ExecStart=/usr/bin/ipfs daemon
Restart=on-failure
[Install]
WantedBy=default.target
To run this in your user session, save it as ~/.config/systemd/user/ipfs.service
(creating directories as necessary). Once you run ipfs init
to create your IPFS settings, you can control the daemon using the following commands:
systemctl --user start ipfs
- start the daemonsystemctl --user stop ipfs
- stop the daemonsystemctl --user status ipfs
- get status of the daemonsystemctl --user enable ipfs
- enable starting the daemon at bootsystemctl --user disable ipfs
- disable starting the daemon at bootNote: If you want this --user
service to run at system boot, you must enable-linger
on the account that runs the service:
# loginctl enable-linger [user]
Read more about --user
services here: wiki.archlinux.org:Systemd
service
or your distribution's equivalent to control the service.cat /etc/init/ipfs.conf
description "ipfs: interplanetary filesystem"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]
limit nofile 524288 1048576
limit nproc 524288 1048576
setuid jbenet
chdir /home/jbenet
respawn
exec ipfs daemon
Another version is available here:
ipfs cat /ipfs/QmbYCwVeA23vz6mzAiVQhJNa2JSiRH4ebef1v2e5EkDEZS/ipfs.conf >/etc/init/ipfs.conf
For both, edit to replace occurrences of jbenet
with whatever user you want it to run as:
sed -i s/jbenet/<chosen-username>/ /etc/init/ipfs.conf
Once you run ipfs init
to create your IPFS settings, you can control the daemon using the init.d
commands:
sudo service ipfs start
sudo service ipfs stop
sudo service ipfs restart
...
Similar to systemd
, on macOS you can run go-ipfs
via a user LaunchAgent.
~/Library/LaunchAgents/io.ipfs.go-ipfs.plist
:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>io.ipfs.go-ipfs</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>~/go/bin/ipfs daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The reason for running ipfs
under a shell is to avoid needing to hard-code the user's home directory in the job.
launchctl load ~/Library/LaunchAgents/io.ipfs.go-ipfs.plist
Notes:
launchctl list | grep ipfs
.go-ipfs can be started by your operating system's native init system.
For systemd
, the best approach is to run the daemon in a user session. Here is a sample service file:
[Unit]
Description=IPFS daemon
[Service]
# Environment="IPFS_PATH=/data/ipfs" # optional path to ipfs init directory if not default ($HOME/.ipfs)
ExecStart=/usr/bin/ipfs daemon
Restart=on-failure
[Install]
WantedBy=default.target
To run this in your user session, save it as ~/.config/systemd/user/ipfs.service
(creating directories as necessary). Once you run ipfs init
to create your IPFS settings, you can control the daemon using the following commands:
systemctl --user start ipfs
- start the daemonsystemctl --user stop ipfs
- stop the daemonsystemctl --user status ipfs
- get status of the daemonsystemctl --user enable ipfs
- enable starting the daemon at bootsystemctl --user disable ipfs
- disable starting the daemon at bootNote: If you want this --user
service to run at system boot, you must enable-linger
on the account that runs the service:
# loginctl enable-linger [user]
Read more about --user
services here: wiki.archlinux.org:Systemd
service
or your distribution's equivalent to control the service.cat /etc/init/ipfs.conf
description "ipfs: interplanetary filesystem"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]
limit nofile 524288 1048576
limit nproc 524288 1048576
setuid jbenet
chdir /home/jbenet
respawn
exec ipfs daemon
Another version is available here:
ipfs cat /ipfs/QmbYCwVeA23vz6mzAiVQhJNa2JSiRH4ebef1v2e5EkDEZS/ipfs.conf >/etc/init/ipfs.conf
For both, edit to replace occurrences of jbenet
with whatever user you want it to run as:
sed -i s/jbenet/<chosen-username>/ /etc/init/ipfs.conf
Once you run ipfs init
to create your IPFS settings, you can control the daemon using the init.d
commands:
sudo service ipfs start
sudo service ipfs stop
sudo service ipfs restart
...
Similar to systemd
, on macOS you can run go-ipfs
via a user LaunchAgent.
~/Library/LaunchAgents/io.ipfs.go-ipfs.plist
:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>io.ipfs.go-ipfs</string>
<key>ProcessType</key>
<string>Background</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>~/go/bin/ipfs daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The reason for running ipfs
under a shell is to avoid needing to hard-code the user's home directory in the job.
launchctl load ~/Library/LaunchAgents/io.ipfs.go-ipfs.plist
Notes:
launchctl list | grep ipfs
.此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。