如何确保网络完全连接后启动systemd服务?

如何确保网络完全连接后启动systemd服务?

系统

  • 硬件:树莓派4
  • 操作系统:Manjaro Arm
  • 网络应用程序:systemd-networkd

我觉得我已经尽一切努力确保一旦建立网络连接就会调用我的测试机器人,但我仍然收到查找地址信息失败错误。

网络守护进程等待在线状态

$ sudo systemctl is-enabled systemd-networkd-wait-online
enabled

网络配置

$ cat 20-wired.network 
[Match]
Name=enp1s0

[Network]
DHCP=ipv6

测试机器人服务

[Unit]
Description=Test bot
Wants=network-online.target
After=network-online.target

[Service]
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin/:/bin" "TZ=CEST"
Type=simple
ExecStart=/usr/bin/testbot
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
User=folaht
SyslogIdentifier=testbot

[Install]
WantedBy=multi-user.target

系统日志

$ sudo journalctl -u testbot
...
jui 15 08:11:14 Klav testbot[272] Error: Io(Custom { kind: Other, error: "failed to lookup address information: Temporary failure in name resolution" })
...

守护进程状态

$ sudo systemctl status testbot
[sudo] Mot de passe de folaht : 
● testbot.service - Test bot.
     Loaded: loaded (/usr/lib/systemd/system/testbot.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Sun 2020-05-24 13:55:51 CEST; 1min 16s ago
    Process: 272 ExecStart=/usr/bin/testbot (code=exited, status=1/FAILURE)
   Main PID: 272 (code=exited, status=1/FAILURE)

mai 24 13:55:51 Klav systemd[1]: testbot.service: Scheduled restart job, restart counter is at 5.
mai 24 13:55:51 Klav systemd[1]: Stopped Test bot..
mai 24 13:55:51 Klav systemd[1]: testbot.service: Start request repeated too quickly.
mai 24 13:55:51 Klav systemd[1]: test.service: Failed with result 'exit-code'.
mai 24 13:55:51 Klav systemd[1]: Failed to start Test bot..

[编辑]

我最近改变Name=enp1s0Name=eth0,它似乎有效。

相关内容