1 Star 0 Fork 0

filecoin-project/go-ipfs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.circleci
.github
assets
bin
blocks/blockstoreutil
cmd
commands
core
coverage
docs
fuse
gc
keystore
misc
completion
launchd
systemd
README.md
mk
namesys
p2p
peering
plugin
repo
snap
tar
test
thirdparty
.codeclimate.yml
.dockerignore
.gitattributes
.gitignore
.gitmodules
.mailmap
CHANGELOG.md
CONTRIBUTING.md
Dockerfile
GNUmakefile
LICENSE
LICENSE-APACHE
LICENSE-MIT
Makefile
README.md
Rules.mk
appveyor.yml
codecov.yml
doc.go
go.mod
go.sum
package-list.json
version.go
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

init system integration

go-ipfs can be started by your operating system's native init system.

systemd

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 daemon
  • systemctl --user stop ipfs - stop the daemon
  • systemctl --user status ipfs - get status of the daemon
  • systemctl --user enable ipfs - enable starting the daemon at boot
  • systemctl --user disable ipfs - disable starting the daemon at boot

Note: 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

initd

upstart

  • And below is a very basic sample upstart job. Note the username jbenet.
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
...

launchd

Similar to systemd, on macOS you can run go-ipfs via a user LaunchAgent.

  • Create ~/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.

  • To start the job, run launchctl load ~/Library/LaunchAgents/io.ipfs.go-ipfs.plist

Notes:

  • To check that the job is running, run launchctl list | grep ipfs.
  • IPFS should now start whenever you log in (and exit when you log out).
  • LaunchControl is a GUI tool which simplifies management of LaunchAgents.## init system integration

go-ipfs can be started by your operating system's native init system.

systemd

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 daemon
  • systemctl --user stop ipfs - stop the daemon
  • systemctl --user status ipfs - get status of the daemon
  • systemctl --user enable ipfs - enable starting the daemon at boot
  • systemctl --user disable ipfs - disable starting the daemon at boot

Note: 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

initd

upstart

  • And below is a very basic sample upstart job. Note the username jbenet.
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
...

launchd

Similar to systemd, on macOS you can run go-ipfs via a user LaunchAgent.

  • Create ~/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.

  • To start the job, run launchctl load ~/Library/LaunchAgents/io.ipfs.go-ipfs.plist

Notes:

  • To check that the job is running, run launchctl list | grep ipfs.
  • IPFS should now start whenever you log in (and exit when you log out).
  • LaunchControl is a GUI tool which simplifies management of LaunchAgents.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ipfs2/go-ipfs.git
git@gitee.com:ipfs2/go-ipfs.git
ipfs2
go-ipfs
go-ipfs
master

搜索帮助