Skip to content

Commit

Permalink
fix mqtt secondary task cliend id
Browse files Browse the repository at this point in the history
  • Loading branch information
oscgonfer committed Sep 25, 2024
1 parent 1463da4 commit 12f1f6b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compose/mqtt-task-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ services:
mqtt-task:
build: ../
env_file: ../.env
command: bundle exec rake mqtt:sub
command: ./mqtt_subscriber.sh
restart: always
volumes:
- "../log:/app/log"
Expand Down
2 changes: 1 addition & 1 deletion compose/mqtt-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
file: mqtt-task-common.yml
service: mqtt-task
environment:
MQTT_CLIENT_ID: "smartcitizen-api-staging-secondary-${HOSTNAME}"
MQTT_CLIENT_ID: "smartcitizen-api-staging-secondary"
MQTT_CLEAN_SESSION: true
deploy:
mode: replicated
Expand Down
6 changes: 6 additions & 0 deletions lib/tasks/mqtt_subscriber.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ namespace :mqtt do
mqtt_port = ENV.has_key?('MQTT_PORT') ? ENV['MQTT_PORT'] : 1883
mqtt_ssl = ENV.has_key?('MQTT_SSL') ? ENV['MQTT_SSL'] : false
mqtt_shared_subscription_group = ENV.fetch("MQTT_SHARED_SUBSCRIPTION_GROUP", nil)

mqtt_topics_string = ENV.fetch('MQTT_TOPICS', '')
mqtt_topics = mqtt_topics_string.include?(",") ? mqtt_topics_string.split(",") : [ mqtt_topics_string ]

if mqtt_shared_subscription_group && mqtt_clean_session
mqtt_client_id += "-#{ENV.fetch("HOSTNAME")}"
end

mqtt_log = Logger.new("log/mqtt-#{mqtt_client_id}.log", 5, 100.megabytes)
mqtt_log.info('MQTT TASK STARTING')
mqtt_log.info("clean_session: #{mqtt_clean_session}")
Expand Down
2 changes: 2 additions & 0 deletions mqtt_subscriber.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
bundle exec rake mqtt:sub

0 comments on commit 12f1f6b

Please sign in to comment.