Syntax cleanup pass.

This commit is contained in:
Lorenzo Stoakes 2014-09-15 12:31:14 +01:00 committed by Pablo Carranza Vélez
parent 70eef70be2
commit f39b51885d
7 changed files with 35 additions and 30 deletions

View File

@ -71,7 +71,7 @@ knex('config').select('value').where(key: 'uuid').then ([uuid]) ->
.then (apps) -> .then (apps) ->
Promise.all(apps.map(application.start)) Promise.all(apps.map(application.start))
.catch (error) -> .catch (error) ->
console.error("Error starting apps:", error) console.error('Error starting apps:', error)
.then -> .then ->
console.log('Starting periodic check for updates..') console.log('Starting periodic check for updates..')
setInterval(-> setInterval(->

View File

@ -111,7 +111,7 @@ exports.start = start = (app) ->
stream.on('end', resolve) stream.on('end', resolve)
.then -> .then ->
console.log("Creating container:", app.imageId) console.log('Creating container:', app.imageId)
updateDeviceInfo(status: 'Starting') updateDeviceInfo(status: 'Starting')
ports = {} ports = {}
if portList? if portList?
@ -195,7 +195,7 @@ exports.update = update = ->
apikey: apiKey apikey: apiKey
) )
.then (remoteApps) -> .then (remoteApps) ->
console.log("Remote apps") console.log('Remote apps')
remoteApps = _.filter(remoteApps, 'commit') remoteApps = _.filter(remoteApps, 'commit')
remoteApps = _.map remoteApps, (app) -> remoteApps = _.map remoteApps, (app) ->
env = env =
@ -217,21 +217,22 @@ exports.update = update = ->
remoteImages = _.keys(remoteApps) remoteImages = _.keys(remoteApps)
console.log(remoteImages) console.log(remoteImages)
console.log("Local apps") console.log('Local apps')
apps = _.indexBy(apps, 'imageId') apps = _.indexBy(apps, 'imageId')
localApps = _.mapValues(apps, (app) -> _.pick(app, ['appId', 'commit', 'imageId', 'env'])) localApps = _.mapValues apps, (app) ->
_.pick(app, [ 'appId', 'commit', 'imageId', 'env' ])
localImages = _.keys(localApps) localImages = _.keys(localApps)
console.log(localImages) console.log(localImages)
console.log("Apps to be removed") console.log('Apps to be removed')
toBeRemoved = _.difference(localImages, remoteImages) toBeRemoved = _.difference(localImages, remoteImages)
console.log(toBeRemoved) console.log(toBeRemoved)
console.log("Apps to be installed") console.log('Apps to be installed')
toBeInstalled = _.difference(remoteImages, localImages) toBeInstalled = _.difference(remoteImages, localImages)
console.log(toBeInstalled) console.log(toBeInstalled)
console.log("Apps to be updated") console.log('Apps to be updated')
toBeUpdated = _.intersection(remoteImages, localImages) toBeUpdated = _.intersection(remoteImages, localImages)
toBeUpdated = _.filter toBeUpdated, (imageId) -> toBeUpdated = _.filter toBeUpdated, (imageId) ->
return !_.isEqual(remoteApps[imageId], localApps[imageId]) return !_.isEqual(remoteApps[imageId], localApps[imageId])

View File

@ -86,7 +86,8 @@ exports.initialised = currentSupervisor.then (currentSupervisor) ->
supervisorUpdating = Promise.resolve() supervisorUpdating = Promise.resolve()
exports.update = -> exports.update = ->
# Make sure only one attempt to update the full supervisor is running at a time, ignoring any errors from previous update attempts # Make sure only one attempt to update the full supervisor is running at
# a time, ignoring any errors from previous update attempts.
supervisorUpdating = supervisorUpdating.catch(->).then -> supervisorUpdating = supervisorUpdating.catch(->).then ->
utils.mixpanelTrack('Supervisor update check') utils.mixpanelTrack('Supervisor update check')
console.log('Fetching supervisor:', remoteImage) console.log('Fetching supervisor:', remoteImage)

View File

@ -3,7 +3,8 @@ process.on 'uncaughtException', (e) ->
supervisor = require './supervisor-update' supervisor = require './supervisor-update'
# Make sure the supervisor-update has initialised before we continue, as it will handle restarting to add mounts if necessary. # Make sure the supervisor-update has initialised before we continue, as it will
# handle restarting to add mounts if necessary.
supervisor.initialised.then -> supervisor.initialised.then ->
knex = require './db' knex = require './db'

View File

@ -35,7 +35,9 @@ exports.findIpAddrs = ->
# We only care about LOCAL routes (not UNICAST or BROADCAST) # We only care about LOCAL routes (not UNICAST or BROADCAST)
if line.match(/LOCAL$/) if line.match(/LOCAL$/)
# Then we make sure the previous line was an ending branch (and hence contains an IP - 127.0.0.0 has BROADCAST and LOCAL entries) # Then we make sure the previous line was an ending branch (and
# hence contains an IP - 127.0.0.0 has BROADCAST and LOCAL
# entries)
if prevLine.match(/^\|--/) if prevLine.match(/^\|--/)
# Then we remove the ending branch bit # Then we remove the ending branch bit
maybeAddr = prevLine.replace(/^\|--/, '').trim() maybeAddr = prevLine.replace(/^\|--/, '').trim()
@ -58,6 +60,6 @@ exports.blink = (ms = 200) ->
exports.checkConnectivity = (host = '8.8.8.8') -> exports.checkConnectivity = (host = '8.8.8.8') ->
ping.sys.promise_probe(host, ping.sys.promise_probe(host,
timeout: 1 timeout: 1
extra: ["-c 1"] extra: [ '-c 1' ]
).then (res) -> ).then (res) ->
return res.alive return res.alive