Skip to content

Commit 9a3b757

Browse files
committed
wip
Signed-off-by: Davide Briani <davide.briani@secomind.com>
1 parent 99b863f commit 9a3b757

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ VERNEMQ_ENABLE_SSL_LISTENER=true
1919

2020
CLUSTERING_STRATEGY=docker-compose
2121
RELEASE_COOKIE=astarte-docker-compose
22+
# DOCKER_VERNEMQ_DISTRIBUTED_COOKIE=vmq

apps/astarte_appengine_api/config/config.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ config :astarte_appengine_api, swagger_ui: true
5959

6060
config :astarte_appengine_api, :max_results_limit, 10000
6161

62+
# Nodes will only connect to each other if they were explicitly connected once before
63+
config :kernel,
64+
# dist_auto_connect: :never,
65+
prevent_overlapping_partitions: false
66+
6267
# Import environment specific config. This must remain at the bottom
6368
# of this file so it overrides the configuration defined above.
6469
import_config "#{config_env()}.exs"

apps/astarte_appengine_api/lib/astarte_appengine_api/config.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,25 @@ defmodule Astarte.AppEngine.API.Config do
289289
query: "astarte-data-updater-plant",
290290
node_basename: "astarte_data_updater_plant"
291291
]
292+
],
293+
vernemq: [
294+
strategy: Elixir.Cluster.Strategy.DNSPoll,
295+
connect: {__MODULE__, :cluster_vernemq_connect, []},
296+
config: [
297+
polling_interval: 5_000,
298+
query: "vernemq",
299+
node_basename: "VerneMQ"
300+
]
292301
]
293302
]
294303
end
295304
end
296305

306+
def cluster_vernemq_connect(node_name) do
307+
Node.set_cookie(node_name, :vmq)
308+
Node.connect(node_name)
309+
end
310+
297311
@doc """
298312
Returns cassandra nodes formatted in the Xandra format
299313
"""

apps/astarte_appengine_api/rel/env.sh.eex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export RELEASE_DISTRIBUTION=name
44

55
if [ -z "$MY_POD_IP" ]
66
then
7-
HOSTNAME=`hostname -i`
8-
export RELEASE_NODE="<%= @release.name %>@$HOSTNAME"
7+
HOSTNAME=$(hostname -i)
8+
export RELEASE_NODE=<%= @release.name %>@${HOSTNAME}
99
else
10-
export RELEASE_NODE="<%= @release.name %>@$MY_POD_IP"
10+
export RELEASE_NODE=<%= @release.name %>@${MY_POD_IP}
1111
fi

apps/astarte_data_updater_plant/config/config.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ config :astarte_data_updater_plant, ecto_repos: [Astarte.DataUpdaterPlant.Repo]
2323

2424
config :astarte_data_updater_plant, Astarte.DataUpdaterPlant.Repo, []
2525

26+
# Nodes will only connect to each other if they were explicitly connected once before
27+
config :kernel,
28+
# dist_auto_connect: :never,
29+
prevent_overlapping_partitions: false
30+
2631
import_config "#{config_env()}.exs"

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ services:
245245

246246
# VerneMQ
247247
vernemq:
248-
image: astarte/vernemq:1.2.0
248+
image: astarte/vernemq:cluster
249+
deploy:
250+
replicas: 2
249251
env_file:
250252
- ./.env
251253
environment:

0 commit comments

Comments
 (0)