更改守护程序服务中的IPFS回购位置

发布于 2025-02-03 13:03:20 字数 2767 浏览 2 评论 0 原文

我正在努力创建一个维护IPFS守护程序的服务,这是私人IPFS网络的一部分。

尝试&我可以轻松地将IPF放入所有用户,我选择在AN /OPT文件夹中初始化IPFS存储库。我在 /etc/bash.bashrc 中设置IPFS_PATH,以便所有用户的默认位置在此/OPT文件夹中:

18:53:02 [foo@server ~]
$ echo $IPFS_PATH
/opt/ipfsNode/.ipfs

完成此操作后,我成功初始化了我的IPFS Repo&amp&能够按预期启动守护程序。

$ ipfs daemon
Initializing daemon...
go-ipfs version: 0.12.2
Repo version: 12
System version: amd64/linux
Golang version: go1.16.15
Swarm is limited to private network of peers with the swarm key
Swarm key fingerprint: [redacted]
Swarm listening on /ip4/<ip>/tcp/4001
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/<ip>/tcp/4001
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/<ip>/tcp/5001
WebUI: http://<ip>:5001/webui
Gateway (readonly) server listening on /ip4/<ip>/tcp/8080
Daemon is ready

要将其转换为服务,我使用 /etc/systemd/systemd/systemd/ypfs.service 上创建此服务定义。 /2019/03/ipfs-network-data-replication.html“ rel =“ nofollow noreferrer”> eleks lab

[Unit]
 Description=IPFS Daemon
 After=syslog.target network.target remote-fs.target nss-lookup.target
 [Service]
 Type=simple
 ExecStart=/usr/local/bin/ipfs daemon --enable-namesys-pubsub
 User=foo
 [Install]
 WantedBy=multi-user.target

但是,它似乎尝试&amp;在我的主目录之上初始化的回购〜/.ipfs 而不是 $ {ipfs_path}/。ipfs 启动服务时。我如何更改它以找到我已经初始化的回购?

● ipfs.service - IPFS Daemon
     Loaded: loaded (/etc/systemd/system/ipfs.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2022-06-01 18:43:03 UTC; 17min ago
    Process: 227966 ExecStart=/usr/local/bin/ipfs daemon --enable-namesys-pubsub (code=exited, status=1/FAILURE)
   Main PID: 227966 (code=exited, status=1/FAILURE)

Jun 01 18:43:03 <server> systemd[1]: Started IPFS Daemon.
Jun 01 18:43:03 <server> ipfs[227966]: Initializing daemon...
Jun 01 18:43:03 <server> ipfs[227966]: go-ipfs version: 0.12.2
Jun 01 18:43:03 <server> ipfs[227966]: Repo version: 12
Jun 01 18:43:03 <server> ipfs[227966]: System version: amd64/linux
Jun 01 18:43:03 <server> ipfs[227966]: Golang version: go1.16.15
Jun 01 18:43:03 <server> ipfs[227966]: Error: no IPFS repo found in /home/foo/.ipfs.
Jun 01 18:43:03 <server> ipfs[227966]: please run: 'ipfs init'
Jun 01 18:43:03 <server> systemd[1]: ipfs.service: Main process exited, code=exited, status=1/FAILURE
Jun 01 18:43:03 <server> systemd[1]: ipfs.service: Failed with result 'exit-code'.

I'm working to create a service that maintains an IPFS daemon, as part of a private IPFS network.

To try & keep the IPFS into available to all users easily, I chose to initialize the IPFS repo in an /opt folder. I set IPFS_PATH in /etc/bash.bashrc such that the default location for all users is in this /opt folder:

18:53:02 [foo@server ~]
$ echo $IPFS_PATH
/opt/ipfsNode/.ipfs

Once this was completed, I successfully initialized my IPFS repo & was able to start the daemon as expected.

$ ipfs daemon
Initializing daemon...
go-ipfs version: 0.12.2
Repo version: 12
System version: amd64/linux
Golang version: go1.16.15
Swarm is limited to private network of peers with the swarm key
Swarm key fingerprint: [redacted]
Swarm listening on /ip4/<ip>/tcp/4001
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/<ip>/tcp/4001
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/<ip>/tcp/5001
WebUI: http://<ip>:5001/webui
Gateway (readonly) server listening on /ip4/<ip>/tcp/8080
Daemon is ready

To transition this into a service, I created this service definition at /etc/systemd/system/ipfs.service, using an example from an Eleks lab:

[Unit]
 Description=IPFS Daemon
 After=syslog.target network.target remote-fs.target nss-lookup.target
 [Service]
 Type=simple
 ExecStart=/usr/local/bin/ipfs daemon --enable-namesys-pubsub
 User=foo
 [Install]
 WantedBy=multi-user.target

However, it seems to try & use a repo initialized on top of my home directory ~/.ipfs instead of ${IPFS_PATH}/.ipfs when the service is started. How can I change this to find the repo I've already initialized?

● ipfs.service - IPFS Daemon
     Loaded: loaded (/etc/systemd/system/ipfs.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2022-06-01 18:43:03 UTC; 17min ago
    Process: 227966 ExecStart=/usr/local/bin/ipfs daemon --enable-namesys-pubsub (code=exited, status=1/FAILURE)
   Main PID: 227966 (code=exited, status=1/FAILURE)

Jun 01 18:43:03 <server> systemd[1]: Started IPFS Daemon.
Jun 01 18:43:03 <server> ipfs[227966]: Initializing daemon...
Jun 01 18:43:03 <server> ipfs[227966]: go-ipfs version: 0.12.2
Jun 01 18:43:03 <server> ipfs[227966]: Repo version: 12
Jun 01 18:43:03 <server> ipfs[227966]: System version: amd64/linux
Jun 01 18:43:03 <server> ipfs[227966]: Golang version: go1.16.15
Jun 01 18:43:03 <server> ipfs[227966]: Error: no IPFS repo found in /home/foo/.ipfs.
Jun 01 18:43:03 <server> ipfs[227966]: please run: 'ipfs init'
Jun 01 18:43:03 <server> systemd[1]: ipfs.service: Main process exited, code=exited, status=1/FAILURE
Jun 01 18:43:03 <server> systemd[1]: ipfs.service: Failed with result 'exit-code'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

歌枕肩 2025-02-10 13:03:20

这是一个非常古老的问题,所以我想您已经弄清楚了 - 但是由于没有答案,我花了很多时间克服了相同的情况,所以我所做的是使它起作用:

  • 由于该服务需要一个用户,您需要将其创建为用户服务:〜/.config/.config/systemd/user/ipfs.service
  • 设置 after = 服务文件的条件以等待要安装的外部磁盘,例如 after = network.target dev-disk-by \ x2dlabel-&lt; devicelabel&gt; .device (并在启动期间将此设备设置为自动板)
  • 启用在系统启动期间的用户服务,无论用户登录如何 loginctl enable-linger&lt; user&gt;

都应该工作。

This is quite an old question, so I suppose you have already figured it out - but since there's no answer and I spent a lot of time to overcome the same situation, here's what I have done to make it work:

  • Since the service requires an user, you need to create it as an user service: ~/.config/systemd/user/ipfs.service
  • Set the After= condition of your service file to wait for the external disk to be mounted, E.G. After=network.target dev-disk-by\x2dlabel-<DEVICELABEL>.device (and remeber to set this device to auto-mount during boot)
  • Enable the user service during system boots, regardless of user log in loginctl enable-linger <USER>

It should work then.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文