mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
Don't auto-migrate because it's slow when many processes have to do the same.
This commit is contained in:
parent
5183485a53
commit
8f90ce0e02
2 changed files with 131 additions and 97 deletions
31
lib/cli.js
31
lib/cli.js
|
@ -435,6 +435,23 @@ program
|
|||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('migrate')
|
||||
.description('migrates the database to the latest version')
|
||||
.action(function() {
|
||||
var log = logger.createLogger('cli:migrate')
|
||||
, db = require('./db')
|
||||
|
||||
db.setup()
|
||||
.then(function() {
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.fatal('Migration had an error:', err.stack)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('local [serial..]')
|
||||
.description('start everything locally')
|
||||
|
@ -485,9 +502,15 @@ program
|
|||
.option('-d, --disable-watch'
|
||||
, 'disable watching resources')
|
||||
.action(function() {
|
||||
var log = logger.createLogger('cli')
|
||||
var log = logger.createLogger('cli:local')
|
||||
, options = cliutil.lastArg(arguments)
|
||||
, db = require('./db')
|
||||
|
||||
// Each forked process waits for signals to stop, and we run over the
|
||||
// default limit of 10. So, it's not a leak, but a refactor wouldn't hurt.
|
||||
process.setMaxListeners(20)
|
||||
|
||||
function run() {
|
||||
var procs = [
|
||||
// app triproxy
|
||||
procutil.fork(__filename, [
|
||||
|
@ -582,7 +605,7 @@ program
|
|||
log.info('Received SIGTERM, waiting for processes to terminate')
|
||||
})
|
||||
|
||||
Promise.all(procs)
|
||||
return Promise.all(procs)
|
||||
.then(function() {
|
||||
process.exit(0)
|
||||
})
|
||||
|
@ -593,6 +616,10 @@ program
|
|||
process.exit(1)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
procutil.fork(__filename, ['migrate'])
|
||||
.then(run)
|
||||
})
|
||||
|
||||
program.parse(process.argv)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var setup = require('./setup')
|
||||
var rutil = require('../util/rutil')
|
||||
var logger = require('../util/logger')
|
||||
var lifecycle = require('../util/lifecycle')
|
||||
|
||||
function connect() {
|
||||
var log = logger.createLogger('db')
|
||||
|
@ -11,11 +12,10 @@ function connect() {
|
|||
, authKey: process.env.RDB_AUTHKEY
|
||||
})
|
||||
.then(function(conn) {
|
||||
conn.on('error', function(err) {
|
||||
return conn.on('error', function(err) {
|
||||
log.fatal('Connection error', err.stack)
|
||||
process.exit(1)
|
||||
lifecycle.fatal()
|
||||
})
|
||||
return setup(conn)
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.fatal('Unable to connect to the database: "%s"', err.message)
|
||||
|
@ -46,3 +46,10 @@ db.run = function(q, options) {
|
|||
return rutil.run(conn, q, options)
|
||||
})
|
||||
}
|
||||
|
||||
// Sets up the database
|
||||
db.setup = function() {
|
||||
return db.connect().then(function(conn) {
|
||||
return setup(conn)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue