mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-18 17:00:25 +00:00
Enclose publish queuing vars in their own closure
This commit is contained in:
parent
7c33f28724
commit
39261f5d6b
@ -23,11 +23,9 @@ pubnub = PUBNUB.init(config.pubnub)
|
||||
|
||||
# Queue up any calls to publish while we wait for the uuid to return from
|
||||
# the sqlite db
|
||||
publish = do ->
|
||||
publishQueue = []
|
||||
|
||||
publish = ->
|
||||
publishQueue.push(arguments)
|
||||
|
||||
knex('config').select('value').where(key: 'uuid').then ([uuid]) ->
|
||||
uuid = uuid.value
|
||||
channel = "device-#{uuid}-logs"
|
||||
@ -36,7 +34,9 @@ knex('config').select('value').where(key: 'uuid').then ([uuid]) ->
|
||||
pubnub.publish({channel, message})
|
||||
|
||||
# Replay queue now that we have initialised the publish function
|
||||
publish.apply(null, args) for args in publishQueue
|
||||
publish(args...) for args in publishQueue
|
||||
|
||||
return -> publishQueue.push(arguments)
|
||||
|
||||
exports.kill = kill = (app) ->
|
||||
docker.listContainersAsync(all: 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user