Skip to content

Instantly share code, notes, and snippets.

@vacquah
Created September 18, 2023 18:27
Show Gist options
  • Save vacquah/c9a52b67adc0c7cf808779050b54be34 to your computer and use it in GitHub Desktop.
Save vacquah/c9a52b67adc0c7cf808779050b54be34 to your computer and use it in GitHub Desktop.
vernemq.nomad.hcl
job "verneMQ" {
datacenters = ["dc1"]
type = "service"
group "verneMQ" {
count = 3
restart {
attempts = 3
interval = "30s"
delay = "15s"
mode = "delay"
}
task "verneMQ" {
driver = "docker"
config {
image = "vernemq/vernemq:latest"
port_map {
mqtt = 1883
mqtts = 8883
mgmt = 8888
ws = 8080
wss = 8081
}
env {
VMQ_DISCOVERY_NODE = "consul"
VMQ_DISCOVERY_HOST = "consul.service.consul" # Replace with your Consul service address.
VMQ_DISCOVERY_INTERVAL = "5s" # Adjust discovery interval as needed.
DOCKER_VERNEMQ_ALLOW_ANONYMOUS = "on" # set to off when working and users configured
DOCKER_VERNEMQ_ACCEPT_EULA = "yes"
DOCKER_VERNEMQ_PLUGINS = "vmq_passwd=on,vmq_acl=on,vmq_webhooks=on"
DOCKER_VERNEMQ_DISCOVERY_CONSUL = "1"
}
volumes = [
"/path/to/your/vernemq.conf:/etc/vernemq/vernemq.conf",
"/path/to/passwords:/etc/vernemq/passwords",
"/path/to/logs:/var/log/vernemq",
"/path/to/acl:/etc/vernemq/acl"
]
}
resources {
cpu = 500 # CPU resources (in MHz)
memory = 256 # Memory resources (in MB)
}
# Specify health checks for VerneMQ instances
check {
type = "tcp"
name = "tcp"
interval = "10s"
timeout = "2s"
}
# Consul service registration for VerneMQ
service {
name = "vernemq"
port = "mqtt"
tags = ["vernemq"]
check {
type = "tcp"
interval = "10s"
timeout = "2s"
}
}
}
network {
mode = "bridge"
}
template {
data = <<EOF
# Contents of vernemq.conf
#
listener.tcp.allowed_protocol_versions = 3,4,5
listener.tcp.default = 0.0.0.0:1883
listener.tcp.local = 127.0.0.1:1883
listener.http.default = 127.0.0.1:8888
listener.ws.default = 127.0.0.1:8080
EOF
destination = "local/vernemq.conf"
change_mode = "signal"
}
template {
data = <<EOF
# Contents of acl.conf
# ...
EOF
destination = "local/acl.conf"
change_mode = "signal"
}
template {
data = <<EOF
# Contents of vmq.passwd
# ...
EOF
destination = "local/vmq.passwd"
change_mode = "signal"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment