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([
|
||||||
if not exists
|
knex.schema.hasTable('config').then((exists) ->
|
||||||
knex.schema.createTable('config', (t) ->
|
if not exists
|
||||||
t.string('key').primary()
|
knex.schema.createTable('config', (t) ->
|
||||||
t.string('value')
|
t.string('key').primary()
|
||||||
)
|
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('imageId')
|
t.string('containerId')
|
||||||
t.string('status')
|
t.string('imageId')
|
||||||
)
|
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