Closed rimelink-lorawan closed 2 years ago
理论上不会退出,建议先排查故障原因。
理论上不会退出,建议先排查故障原因。
谢谢您的回复。
排查故障原因很难实现:因为运行 20 天后,在 OpenWrt 的 logread 日志没有 frpc 任何信息,失去了线索。
有办法检测 frpc 还在工作不?如果有,那就好办。
/usr/bin/ping -c 1 192.168.12.1 &> /dev/null && (/usr/bin/logger "INFO: Wireguard alive") || (/usr/bin/logger "ERROR: Wireguard dead, restarting wg-quick@wg0" ; /usr/bin/systemctl restart wg-quick@wg0)
以 wireguard 为例,检测 virtual address 是否 ping 通,查看日志 Wireguard alive or dead,就可以判断 wiregurad 是否正常工作。
这样,就可以编写上面的 watch_wireguard.sh 再加载到 crontab 中当守护
sudo chmod +x /root/watch_wireguard.sh sudo crontab -e
You will see an existing line in this file. Ignore it, and leave it alone. Add a new line which contains:
用supervisor 启动
编写了一个脚本 watch_frpc.sh 并将它加载到 crontab 中 * /usr/local/bin/watch_frpc.sh >> /tmp/watch_frpc.log
要求在 frps 和 frpc 都开启 http 代理,这样,一旦发现 frpc 挂了,脚本 watch_frpc.sh 就能发现,它会重启 frpc
经历多种测试环境(模拟:frps 挂了,frpc 挂了,internet 中断,拨出网线。。。),验证该脚本稳定可靠。
VPS_PORT=vhost_http_port CONFIG_FILE=/usr/local/etc/frpc.ini SYSTEMCTL=$(which systemctl)
vps_ip=$(awk '$1=="server_addr" {print $3}' $CONFIG_FILE)
curl $vps_ip:$VPS_PORT | grep -q -w Unauthorized if [ $? -eq 1 ] then echo "$(date '+%Y-%m-%d %H:%M:%S') [error]: frpc dropped,restart it!" $SYSTEMCTL restart frpc fi
docker
Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
没有更好办法, 怀疑没有挂,只是阻塞了不能再工作了。 我在NAS上面 的解决办法,是每天(周)重启一下。
理论上不会退出,建议先排查故障原因。
谢谢您的回复。
排查故障原因很难实现:因为运行 20 天后,在 OpenWrt 的 logread 日志没有 frpc 任何信息,失去了线索。
有办法检测 frpc 还在工作不?如果有,那就好办。 非Openwrt的原因,我的表现分为:
- 在Openwrt上面,如果不经常使用它,跑三个月也没挂,如果经常使用,估计也就十几天就挂了,挂的表现是它只是不工作了,进程还是正常的。
- 在Nas上面的表现比较容易复现,NAS的cpu比较好,加上每天晚上备份数据都要用,所以NAS也比较容易挂。 解决办法: 定时 重启,通过服务重启。 定时重启后,后来也没发现这类问题出来 。
楼上老铁写的脚本也不错,但是不好移植呀。 不如定时重启来得暴力和有效。
Bug Description
在 OpenWrt 21.02 上安装了 frpc,运行 20 天左右,发现 frpc 已经宕机了。查看服务 service frpc status 显示 running,查看日志 logread -e frpc 没有信息。当然,手动重启 service frpc restart 可以继续工作。
痛点是:部署 frpc 在 OpenWrt 是嵌入式设备,数量众多,且无人值守。手动重启 frpc 不现实。
能检测 frpc 是否正常运行吗?如果有,可以 crontab 添加一个 watch_frpc.sh 脚本,当发现 frpc 宕机时重启 frpc 服务。
frpc Version
0.34.3
frps Version
0.37.1
System Architecture
Linux/amd64
Configurations
[common] server_addr = server_public_ip server_port = 7000 token = my_token protocol = kcp
[web] type = http local_ip = 192.168.2.10 local_port = 80 custom_domains = server_public_ip http_user = my_user http_pwd = my_pwd use_encryption = true use_compression = true
Logs
No response
Steps to reproduce
...
Affected area