diff --git a/lib/tasks/mqtt_subscriber.rake b/lib/tasks/mqtt_subscriber.rake index 6b432a9b..9952eae3 100644 --- a/lib/tasks/mqtt_subscriber.rake +++ b/lib/tasks/mqtt_subscriber.rake @@ -38,10 +38,14 @@ namespace :mqtt do ) client.get do |topic, message| - MqttMessagesHandler.handle_topic(topic, message) - rescue Exception => e - mqtt_log.info e - Sentry.capture_exception(e) + Sentry.with_scope do + begin + MqttMessagesHandler.handle_topic(topic, message) + rescue Exception => e + mqtt_log.info e + Sentry.capture_exception(e) + end + end end end rescue SystemExit, Interrupt, SignalException diff --git a/lib/tasks/telnet.rake b/lib/tasks/telnet.rake index d7d74ea5..98c80e5b 100644 --- a/lib/tasks/telnet.rake +++ b/lib/tasks/telnet.rake @@ -20,12 +20,14 @@ namespace :telnet do p 'Starting Redis subscription...' Redis.current.subscribe('telnet_queue') do |on| on.message do |channel, msg| - #puts "#{channel} - #{msg}" - alldata = JSON.parse(msg) + Sentry.with_scope do + #puts "#{channel} - #{msg}" + alldata = JSON.parse(msg) - alldata.each do |data| - telnet_string = "put #{data['name']} #{data['timestamp']} #{data['value']} device_id=#{data['tags']['device_id']} \n" - localhost.print telnet_string + alldata.each do |data| + telnet_string = "put #{data['name']} #{data['timestamp']} #{data['value']} device_id=#{data['tags']['device_id']} \n" + localhost.print telnet_string + end end end end