Report the commit to the API as soon as the container is started.

This commit is contained in:
Pagan Gazzard 2014-07-19 03:24:01 +01:00 committed by Pablo Carranza Vélez
parent 7a5197d68e
commit b7149bb266
2 changed files with 12 additions and 2 deletions

View File

@ -119,6 +119,7 @@ exports.start = start = (app) ->
]
)
.then ->
updateDeviceInfo(commit: app.commit)
container.attachAsync({ stream: true, stdout: true, stderr: true, tty: true })
.then (stream) ->
es.pipeline(
@ -176,6 +177,7 @@ exports.update = ->
for envVar in app.environment_variable
env[envVar.name] = envVar.value
return {
commit: app.commit
imageId: "#{process.env.REGISTRY_ENDPOINT}/#{path.basename(app.git_repository, '.git')}/#{app.commit}"
env: JSON.stringify(env) # The env has to be stored as a JSON string for knex
}
@ -185,7 +187,7 @@ exports.update = ->
console.log(remoteImages)
console.log("Local apps")
apps = _.map(apps, (app) -> _.pick(app, ['imageId', 'env']))
apps = _.map(apps, (app) -> _.pick(app, ['commit', 'imageId', 'env']))
apps = _.indexBy(apps, 'imageId')
localImages = _.keys(apps)
console.log(localImages)
@ -232,7 +234,7 @@ exports.update = ->
# Set the updating as finished
currentlyUpdating = 0
exports.updateDeviceInfo = (body) ->
exports.updateDeviceInfo = updateDeviceInfo = (body) ->
Promise.all([
knex('config').select('value').where(key: 'apiKey')
knex('config').select('value').where(key: 'uuid')

View File

@ -22,9 +22,17 @@ knex.init = Promise.all([
t.increments('id').primary()
t.string('name')
t.string('containerId')
t.string('commit')
t.string('imageId')
t.boolean('privileged')
t.json('env')
else
knex.schema.hasColumn('app', 'commit')
.then (exists) ->
if not exists
knex.schema.table 'app', (t) ->
t.string('commit')
])
module.exports = knex