BHD钱包部署【生态池/合作池】

前序

BHD网址:https://btchd.org/#wallet

 

注:我这里是centos7, 所以我选linuxPC

部署

解压与配置

1
tar -zxf bhd-v1.3.4.0-d909c0e-x86_64-linux-gnu.tar.gz

注: 大概就长这个样子, 生态池和合作池是一样的, 端口不同而已。

启动之前记得把data目录替换(如果有原数据的话), 添加配置文件btchd.conf

 启动

1
/opt/bhd-wallet/bin/btchdd -datadir=/opt/bhd-wallet/data/

直接nohup也行, supervisord也行, 下面扔个supervisord维护的配置过来

1
2
3
4
5
6
7
8
9
10
11
[program:btchdd_co]
user=root
directory=/opt/bhd-wallet/
environment=LD_LIBRARY_PATH="/opt/bhd-wallet/lib"
command=/opt/bhd-wallet/bin/btchdd -datadir=/opt/bhd-wallet/data/
numprocs=1
startsecs=3
startretries=3
autostart=true
autorestart=true
process_name=%(program_name)s

就这样的启动成功了

验证

1.查看区块

https://btchd.org/explorer/block

对比与自己钱包的块值

1
/opt/bhd-wallet/btchd-cli.sh getMiningInfo

 对比线上最新的+1

 下面还有两条出数据代表正常

1
2
/opt/bhd-wallet/btchd-cli.sh getblockchaininfo
/opt/bhd-wallet/btchd-cli.sh listsignaddresses

告警shell

注:发现钱包掉线马上告警, 主要使用的是getMininfo去获取每个字段中的值, 然后判断非空, 如果有空, 证明钱包挂了, 这是异常情况, 告警。当告警完之后, 获取到数据代表正常,

这个时候再发一条恢复告警提示管理员或者开发人员, 当无挂掉得时候正常显示, 可以使用nohup指定重定向日志。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#*************************************************************************
#         > File Name: btchddProcess.sh
#         > Author: chenglee
#         > Main : chengkenlee@sina.com
#         > Blog : http://www.cnblogs.com/chenglee/
#         > Created Time : 2019年08月22日 星期一 14时28分49秒
#*************************************************************************
#!/bin/bash
 
hostname=`hostname`
NetWorkIP=`ip addr |grep inet |grep -v inet6 |grep eth0|awk '{print $2}' |awk -F "/" '{print $1}'`
 
BtchddProcess="btchdd_co"
count=0
#online
webhook="这里填写你的钉钉机器人告警url"
#test
 
function BTCHDDERROR(){
    currTime1=`echo $(date +"%Y-%m-%d.%T")`
    currchengtime=`echo $(date +"%Y-%m-%d %T")`
    SsPid="$$"
    curl ''$webhook'' \
   -H 'Content-Type: application/json' \
   -d '{"msgtype": "text",
        "text": {
             "content": "
服务器:'$hostname' 发生: '$BtchddProcess'活性故障!
 
[
告警主机:'$hostname'
告警地址:'$NetWorkIP'
监控项目:'$BtchddProcess'
告警等级:高
当前状态:中断
告警信息:'$BtchddProcess' is down
告警时间:'$currTime1'
事件ID:'$SsPid'
]
"
        }
      }'
}
function BTCHDDRESTART(){
    currTime2=`echo $(date +"%Y-%m-%d.%T")`
    currchengtime2=`echo $(date +"%Y-%m-%d %T")`
    SsPid="$$"
    continueTime=$(($(date +%s -d "$currchengtime2") - $(date +%s -d "$currchengtime")));
    curl ''$webhook'' \
   -H 'Content-Type: application/json' \
   -d '{"msgtype": "text",
        "text": {
             "content": "
服务器:'$hostname' 发生: 进程'$BtchddProcess'活性恢复!
 
[
告警主机:'$hostname'
告警地址:'$NetWorkIP'
监控项目:'$BtchddProcess'
告警等级:中
当前状态:运行
告警信息:'$processname' restart success
告警时间:'$currTime1'
恢复时间:'$currTime2'
持续时间:'$continueTime' s
事件ID:'$SsPid'
]
"
        }
      }'
}
 
:<<cheng
function BTCHDDRESTARTOFF(){
    curl ''$webhook'' \
   -H 'Content-Type: application/json' \
   -d '{"msgtype": "text",
        "text": {
             "content": "高级告警:[主机:'$hostname' - 进程:'$BtchddProcess' - 操作:活性检测异常 - 状态:重启失败]"
        }
      }'
}
cheng
 
function BTCHDDSUCC(){
    curl ''$webhook'' \
   -H 'Content-Type: application/json' \
   -d '{"msgtype": "text",
        "text": {
             "content": "高级告警:[主机:'$hostname' - 进程:'$BtchddProcess' - 操作:活性检测异常 - 状态:恢复]"
        }
      }'
}
 
function btstatus(){
    #curl -v -X POST 'http://127.0.0.1:8732/burst?requestType=getMiningInfo' > status
    curl -X POST 'http://localhost:8911/burst?requestType=getMiningInfo' > status
    sleep 2;
    Height=`cat status | awk -F ',' '{print$1}' | awk -F ':' '{print$2}'`
    GenerationSignature=`cat status | awk -F ',' '{print$2}' | awk -F ':' '{print$2}' | awk -F '"' '{print$2}'`
    BaseTarget=`cat status | awk -F ',' '{print$3}' | awk -F ':' '{print$2}' | awk -F '"' '{print$2}'`
    TargetDeadline=`cat status | awk -F ',' '{print$4}' | awk -F ':' '{print$2}'`
    RequestProcessingTime=`cat status | awk -F ',' '{print$5}' | sed 's/}//' | awk -F ':' '{print$2}'`
}
function SKill(){
    Pid=`ps aux | grep "btchdd" | grep -v grep | wc -l`
    if [ $Pid > 0 ];then
        ps aux | grep "btchdd" | grep -v grep | awk -F ' ' '{print$2}' | xargs kill -9
        BTCHDDRESTART
        if [ -z "$Height" -o -z "$GenerationSignature" -o -z "$BaseTarget" -o -z "$TargetDeadline" -o -z "$RequestProcessingTime" ];then
            echo;
        else
            BTCHDDSUCC
        fi
    fi
}
function check(){
    btstatus
    if [ -z "$Height" -o -z "$GenerationSignature" -o -z "$BaseTarget" -o -z "$TargetDeadline" -o -z "$RequestProcessingTime" ];then
        BTCHDDERROR
        sleep 5;
        count=$[count+1]
        echo "[suspend:$count]"
        echo "#####1:[$Height],2:[$GenerationSignature],3:[$BaseTarget],4:[$TargetDeadline],5:[$RequestProcessingTime]####"
    else
        echo "Success"
        echo "#####1:[$Height],2:[$GenerationSignature],3:[$BaseTarget],4:[$TargetDeadline],5:[$RequestProcessingTime]####"
        sleep 1;
 
        if [ $count -gt 0 ];then
            BTCHDDRESTART
            count=0
            echo "[suspend:$count]"
        fi
    fi
}
function main(){
    while :
    do
        currTime=$(date +"%Y-%m-%d %T")
        echo $currTime
        check
        echo;
        sleep 60;
    done
}
main

 

因为配置了supervisord自动拉起, 所以每次中断的时候就会自动重启。

 

posted @   扶苏公子x  阅读(1174)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性

阅读目录(Content)

此页目录为空

点击右上角即可分享
微信分享提示