Early stage log worker: Next- update procfile.
parent
97882f8c0a
commit
4a45e1b2b2
|
@ -11,10 +11,10 @@ module Transport
|
|||
end
|
||||
|
||||
def self.log_channel
|
||||
@log_channel ||= self.connection
|
||||
.create_channel
|
||||
.queue("", exclusive: true)
|
||||
.bind("amq.topic", routing_key: "bot.*.logs")
|
||||
@log_channel ||= self.connection
|
||||
.create_channel
|
||||
.queue("", exclusive: true)
|
||||
.bind("amq.topic", routing_key: "bot.*.logs")
|
||||
end
|
||||
|
||||
def self.topic
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
binding.pry
|
||||
|
||||
loop do
|
||||
puts "Ding!"
|
||||
sleep 5
|
||||
end
|
||||
Transport
|
||||
.log_channel
|
||||
.subscribe(block: true) do |delivery_info, properties, payload|
|
||||
# Legacy FBOS still uses the API for log storage.
|
||||
headers = properties[:headers] || {}
|
||||
# Guess version
|
||||
not_legacy = !headers.keys.join(" ").include?("mqtt")
|
||||
if (not_legacy)
|
||||
# Extract current user (if version is appropriate)
|
||||
device_id = delivery_info.routing_key.split(".")[1].gsub("device_", "").to_i
|
||||
device = Device.find(device_id)
|
||||
# Parse payload
|
||||
payload = JSON.parse(payload)
|
||||
puts "===== INCOMING LOG ====="
|
||||
puts payload
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue