mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-22 06:57:49 +00:00
Wait for db initialisation before starting app
This commit is contained in:
parent
e5684a1c3a
commit
dc3708d14f
@ -1,3 +1,4 @@
|
|||||||
|
Promise = require 'bluebird'
|
||||||
Knex = require('knex')
|
Knex = require('knex')
|
||||||
|
|
||||||
knex = Knex.initialize(
|
knex = Knex.initialize(
|
||||||
@ -6,22 +7,24 @@ knex = Knex.initialize(
|
|||||||
filename: '/supervisor/data/database.sqlite'
|
filename: '/supervisor/data/database.sqlite'
|
||||||
)
|
)
|
||||||
|
|
||||||
knex.schema.hasTable('config').then((exists) ->
|
knex.init = Promise.all([
|
||||||
|
knex.schema.hasTable('config').then((exists) ->
|
||||||
if not exists
|
if not exists
|
||||||
knex.schema.createTable('config', (t) ->
|
knex.schema.createTable('config', (t) ->
|
||||||
t.string('key').primary()
|
t.string('key').primary()
|
||||||
t.string('value')
|
t.string('value')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
knex.schema.hasTable('app').then((exists) ->
|
||||||
knex.schema.hasTable('app').then((exists) ->
|
|
||||||
if not exists
|
if not exists
|
||||||
knex.schema.createTable('app', (t) ->
|
knex.schema.createTable('app', (t) ->
|
||||||
t.increments('id').primary()
|
t.increments('id').primary()
|
||||||
t.string('name')
|
t.string('name')
|
||||||
|
t.string('containerId')
|
||||||
t.string('imageId')
|
t.string('imageId')
|
||||||
t.string('status')
|
t.boolean('privileged')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
])
|
||||||
|
|
||||||
module.exports = knex
|
module.exports = knex
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
require('coffee-script');
|
require('coffee-script');
|
||||||
require('./app');
|
var knex = require('./db')
|
||||||
|
|
||||||
|
// Wait for the DB schema to be created
|
||||||
|
knex.init.then(function () {
|
||||||
|
require('./app');
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user