mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-20 14:13:08 +00:00
Queue publish calls while getting uuid from db
This commit is contained in:
parent
ca736233e7
commit
7c33f28724
@ -21,7 +21,12 @@ Promise.promisifyAll(docker.getContainer().__proto__)
|
||||
|
||||
pubnub = PUBNUB.init(config.pubnub)
|
||||
|
||||
publish = null
|
||||
# Queue up any calls to publish while we wait for the uuid to return from
|
||||
# the sqlite db
|
||||
publishQueue = []
|
||||
|
||||
publish = ->
|
||||
publishQueue.push(arguments)
|
||||
|
||||
knex('config').select('value').where(key: 'uuid').then ([uuid]) ->
|
||||
uuid = uuid.value
|
||||
@ -30,6 +35,9 @@ knex('config').select('value').where(key: 'uuid').then ([uuid]) ->
|
||||
publish = (message) ->
|
||||
pubnub.publish({channel, message})
|
||||
|
||||
# Replay queue now that we have initialised the publish function
|
||||
publish.apply(null, args) for args in publishQueue
|
||||
|
||||
exports.kill = kill = (app) ->
|
||||
docker.listContainersAsync(all: 1)
|
||||
.then (containers) ->
|
||||
|
Loading…
Reference in New Issue
Block a user