console.log the crap out of startup

This commit is contained in:
Sam Rose 2024-07-24 15:12:23 +01:00
parent 0fb9c78551
commit dfa2437f46
No known key found for this signature in database
1 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import Koa from "koa"
import { Server } from "http"
import { AddressInfo } from "net"
import fs from "fs"
import { c } from "tar"
let STARTUP_RAN = false
@ -80,18 +81,31 @@ export async function startup(
const address = server.address() as AddressInfo
env._set("PORT", address.port)
}
console.log("Emitting port event")
eventEmitter.emitPort(env.PORT)
console.log("Initialising file system")
fileSystem.init()
console.log("Initialising redis")
await redis.init()
console.log("Initialising writethrough cache")
cache.docWritethrough.init()
console.log("Initialising events")
eventInit()
if (app && server) {
console.log("Initialising websockets")
initialiseWebsockets(app, server)
}
// run migrations on startup if not done via http
// not recommended in a clustered environment
if (!env.HTTP_MIGRATIONS && !env.isTest()) {
console.log("Running migrations")
try {
await migrations.migrate()
} catch (e) {
@ -107,12 +121,15 @@ export async function startup(
env.PLUGINS_DIR &&
fs.existsSync(env.PLUGINS_DIR)
) {
console.log("Monitoring plugin directory")
watch()
}
// check for version updates
console.log("Checking for version updates")
await installation.checkInstallVersion()
console.log("Initialising queues")
// get the references to the queue promises, don't await as
// they will never end, unless the processing stops
let queuePromises = []
@ -126,6 +143,7 @@ export async function startup(
}
queuePromises.push(initPro())
if (app) {
console.log("Initialising routes")
// bring routes online as final step once everything ready
await initRoutes(app)
}
@ -141,6 +159,7 @@ export async function startup(
bbAdminEmail &&
bbAdminPassword
) {
console.log("Initialising admin user")
const tenantId = tenancy.getTenantId()
await tenancy.doInTenant(tenantId, async () => {
const exists = await users.doesUserExist(bbAdminEmail)
@ -171,5 +190,6 @@ export async function startup(
})
}
console.log("Initialising JS runner")
jsRunner.init()
}