could listen to unix socket, better conf

This commit is contained in:
lesion
2019-06-10 00:40:37 +02:00
parent d1a56e5135
commit b01f4ef04d
15 changed files with 107 additions and 76 deletions

View File

@@ -10,8 +10,8 @@ if (!fs.existsSync(config_path)) {
process.exit(1)
}
const { SECRET_CONF, SHARED_CONF } = require(config_path)
if (!SECRET_CONF.secret) {
const config = require(config_path)
if (!config.secret) {
console.error(`Please specify a random 'secret' in '${config_path}'!`)
process.exit(1)
}
@@ -19,9 +19,9 @@ if (!SECRET_CONF.secret) {
const Sequelize = require('sequelize')
let db
try {
db = new Sequelize(SECRET_CONF.db)
db = new Sequelize(config.db)
} catch (e) {
console.error(`DB Error: check '${SHARED_CONF.env}' configuration.\n (sequelize error -> ${e})`)
console.error(`DB Error: check '${config.env}' configuration.\n (sequelize error -> ${e})`)
process.exit(1)
}
@@ -29,13 +29,13 @@ try {
module.exports = db.authenticate()
.then(() => {
require('./api/models')
if (SHARED_CONF.env === 'development') {
if (config.env === 'development') {
console.error('DB Force sync')
return db.sync({ force: true })
}
})
.catch(e => {
console.error(e)
console.error(`DB Error: check '${SHARED_CONF.env}' configuration\n (sequelize error -> ${e})`)
console.error(`DB Error: check '${config.env}' configuration\n (sequelize error -> ${e})`)
process.exit(1)
})