budibase/packages/server/src/app.ts

35 lines
728 B
TypeScript
Raw Normal View History

if (process.env.DD_APM_ENABLED) {
require("./ddApm")
}
2022-11-26 16:10:41 +01:00
import * as db from "./db"
2023-11-20 21:52:29 +01:00
db.init()
import { ServiceType } from "@budibase/types"
import { env as coreEnv } from "@budibase/backend-core"
2023-11-20 21:52:29 +01:00
coreEnv._set("SERVICE_TYPE", ServiceType.APPS)
import createKoaApp from "./koa"
import Koa from "koa"
import { Server } from "http"
import { startup } from "./startup"
2020-07-16 15:27:27 +02:00
let app: Koa, server: Server
2023-02-04 19:51:10 +01:00
async function start() {
const koa = createKoaApp()
app = koa.app
server = koa.server
2023-08-21 16:31:35 +02:00
// startup includes automation runner - if enabled
2023-01-31 17:15:11 +01:00
await startup(app, server)
}
start().catch(err => {
console.error(`Failed server startup - ${err.message}`)
2024-02-16 16:13:26 +01:00
throw err
})
2022-08-31 11:47:41 +02:00
export function getServer(): Server {
2023-08-17 17:51:11 +02:00
return server
}