Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
iot-mqtt-bl
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
deploy
iot-mqtt-bl
Commits
a29ab47d
Commit
a29ab47d
authored
Apr 27, 2023
by
吴文龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新版本
parent
e62862ee
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
50 deletions
+15
-50
docker-compose.yml
docker-compose.yml
+2
-1
haproxy copy.cfg
haproxy/config/haproxy copy.cfg
+0
-28
haproxy.cfg
haproxy/config/haproxy.cfg
+4
-1
mqtt_health_check.lua
haproxy/config/mqtt_health_check.lua
+0
-20
check_mqtt.sh
haproxy/data/check_mqtt.sh
+8
-0
test-mqtt.json
haproxy/data/test-mqtt.json
+1
-0
No files found.
docker-compose.yml
View file @
a29ab47d
...
...
@@ -4,9 +4,10 @@ services:
haproxy
:
restart
:
always
container_name
:
"
iot-mqtt-bl"
image
:
thingsboard/haproxy-certbot:1.3
.0
image
:
47.110.145.204:8084/buildenv/tb-haproxy:1.6
.0
volumes
:
-
./haproxy/config:/config
-
./haproxy/data:/usr/local/bin
-
./haproxy/letsencrypt:/etc/letsencrypt
-
./haproxy/certs.d:/usr/local/etc/haproxy/certs.d
ports
:
...
...
haproxy/config/haproxy copy.cfg
deleted
100644 → 0
View file @
e62862ee
global
daemon
maxconn 256
defaults
mode tcp
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend mqtt_frontend
bind *:1883
mode tcp
default_backend mqtt_backend
backend mqtt_backend
mode tcp
balance roundrobin
option tcp-check
tcp-check send-binary 303c01000004000000000000
tcp-check expect binary 200201000004000000000000
tcp-check send-binary 100000016d7174742f04020000000c6d7174742d737461747573
tcp-check expect binary 20020001000c6d7174742d737461747573
server mqtt_server1 192.168.1.101:1883 check inter 5s rise 2 fall 3
server mqtt_server2 192.168.1.102:1883 check inter 5s rise 2 fall 3
server mqtt_server3 192.168.1.103:1883 check inter 5s rise 2 fall 3
lua-load /etc/haproxy/mqtt_health_check.lua
haproxy/config/haproxy.cfg
View file @
a29ab47d
...
...
@@ -46,6 +46,9 @@ listen mqtt-in
timeout server 3h
option tcplog
balance leastconn
option external-check
external-check path "/usr/local/bin:/bin"
external-check command /usr/local/bin/check_mqtt.sh
server tbMqtt1 47.99.83.75:31883 check inter 10s rise 2 fall 3
server tbMqtt2 47.97.197.103:31883 check inter 10s rise 2 fall 3
server tbMqtt3 47.96.103.209:31883 check inter 10s rise 2 fall 3
...
...
haproxy/config/mqtt_health_check.lua
deleted
100644 → 0
View file @
e62862ee
core
.
register_action
(
"mqtt_health_check"
,
{
"tcp-req"
},
function
(
txn
)
txn
:
set_var
(
txn
.
TXN_CHECK_STATUS
,
"L7OK"
)
txn
:
set_var
(
txn
.
TXN_CHECK_CODE
,
"200"
)
txn
:
set_var
(
txn
.
TXN_CHECK_PAYLOAD
,
""
)
if
txn
.
f
:
has_subscribers
()
then
local
ok
,
err
=
txn
.
f
:
publish
(
"mqtt_health_check"
,
"PINGREQ"
)
if
not
ok
then
txn
:
set_var
(
txn
.
TXN_CHECK_STATUS
,
"L7FAIL"
)
txn
:
set_var
(
txn
.
TXN_CHECK_CODE
,
"503"
)
end
end
end
)
core
.
register_subscriber
(
"mqtt_health_check"
,
function
(
applet
)
applet
:
set_status
(
200
)
applet
:
add_header
(
"Content-Type"
,
"text/plain"
)
applet
:
start_response
()
applet
:
send
(
"PONG\n"
)
end
)
haproxy/data/check_mqtt.sh
0 → 100644
View file @
a29ab47d
#!/bin/bash
echo
$@
>>
/tmp/all_arguments.txt
ip_adr
=
$(
echo
$@
|awk
'{print $3}'
)
if
mosquitto_pub
-h
$ip_adr
-p
31883
-u
123456
-t
v1/devices/me/attributes
-f
test-mqtt.json
-q
1
-d
;
then
exit
0
else
exit
1
fi
haproxy/data/test-mqtt.json
0 → 100644
View file @
a29ab47d
{
"check-mqtt"
:
"ok"
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment