add CONFIGURED status to bootstrap before READY
This commit is contained in:
@@ -62,7 +62,7 @@ const db = {
|
|||||||
return umzug.up()
|
return umzug.up()
|
||||||
},
|
},
|
||||||
async initialize () {
|
async initialize () {
|
||||||
if (config.status === 'READY') {
|
if (config.status === 'CONFIGURED') {
|
||||||
try {
|
try {
|
||||||
await db.connect()
|
await db.connect()
|
||||||
log.debug('Running migrations')
|
log.debug('Running migrations')
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ let config = {
|
|||||||
if (fs.existsSync(config_path)) {
|
if (fs.existsSync(config_path)) {
|
||||||
const configContent = fs.readFileSync(config_path)
|
const configContent = fs.readFileSync(config_path)
|
||||||
config = Object.assign(config, JSON.parse(configContent))
|
config = Object.assign(config, JSON.parse(configContent))
|
||||||
config.status = 'READY'
|
config.status = 'CONFIGURED'
|
||||||
if (!config.hostname) {
|
if (!config.hostname) {
|
||||||
config.hostname = new URL.URL(config.baseurl).hostname
|
config.hostname = new URL.URL(config.baseurl).hostname
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ const initialize = {
|
|||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
if (config.status == 'READY') {
|
if (config.status == 'CONFIGURED') {
|
||||||
await db.initialize()
|
await db.initialize()
|
||||||
|
config.status = 'READY'
|
||||||
} else {
|
} else {
|
||||||
if (process.env.GANCIO_DB_DIALECT) {
|
if (process.env.GANCIO_DB_DIALECT) {
|
||||||
const setupController = require('./api/controller/setup')
|
const setupController = require('./api/controller/setup')
|
||||||
|
|||||||
@@ -3,29 +3,27 @@ const cookieParser = require('cookie-parser')
|
|||||||
const app = express()
|
const app = express()
|
||||||
const initialize = require('./initialize.server')
|
const initialize = require('./initialize.server')
|
||||||
|
|
||||||
|
const config = require('./config')
|
||||||
|
const helpers = require('./helpers')
|
||||||
|
app.use(helpers.setUserLocale)
|
||||||
|
app.use(helpers.initSettings)
|
||||||
|
app.use(helpers.logRequest)
|
||||||
|
app.use(helpers.serveStatic())
|
||||||
|
app.use(cookieParser())
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
|
|
||||||
await initialize.start()
|
await initialize.start()
|
||||||
|
|
||||||
// const metricsController = require('./metrics')
|
// const metricsController = require('./metrics')
|
||||||
// const promBundle = require('express-prom-bundle')
|
// const promBundle = require('express-prom-bundle')
|
||||||
// const metricsMiddleware = promBundle({ includeMethod: true })
|
// const metricsMiddleware = promBundle({ includeMethod: true })
|
||||||
|
|
||||||
const config = require('./config')
|
|
||||||
|
|
||||||
const helpers = require('./helpers')
|
|
||||||
const log = require('./log')
|
const log = require('./log')
|
||||||
const api = require('./api')
|
const api = require('./api')
|
||||||
|
|
||||||
app.enable('trust proxy')
|
app.enable('trust proxy')
|
||||||
app.use(helpers.logRequest)
|
|
||||||
|
|
||||||
app.use(helpers.initSettings)
|
|
||||||
app.use(helpers.setUserLocale)
|
|
||||||
app.use(helpers.serveStatic())
|
|
||||||
|
|
||||||
app.use(cookieParser())
|
|
||||||
|
|
||||||
|
|
||||||
// do not handle all routes on setup
|
// do not handle all routes on setup
|
||||||
if (config.status === 'READY') {
|
if (config.status === 'READY') {
|
||||||
|
|||||||
Reference in New Issue
Block a user