2023-02-15 17:28:20 +01:00
|
|
|
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
|
|
|
|
2022-03-29 17:03:44 +02:00
|
|
|
db.init()
|
2023-07-28 16:39:59 +02:00
|
|
|
import { ServiceType } from "@budibase/types"
|
2023-08-17 17:39:25 +02:00
|
|
|
import { env as coreEnv } from "@budibase/backend-core"
|
2023-11-20 21:52:29 +01:00
|
|
|
|
2023-07-28 16:39:59 +02:00
|
|
|
coreEnv._set("SERVICE_TYPE", ServiceType.APPS)
|
2023-08-17 17:39:25 +02:00
|
|
|
import createKoaApp from "./koa"
|
|
|
|
import Koa from "koa"
|
|
|
|
import { Server } from "http"
|
2022-10-27 16:15:08 +02:00
|
|
|
import { startup } from "./startup"
|
2020-07-16 15:27:27 +02:00
|
|
|
|
2023-08-17 17:39:25 +02:00
|
|
|
let app: Koa, server: Server
|
2023-02-04 19:51:10 +01:00
|
|
|
|
2023-08-17 17:39:25 +02:00
|
|
|
async function start() {
|
2023-12-13 12:23:46 +01:00
|
|
|
const koa = createKoaApp()
|
|
|
|
app = koa.app
|
|
|
|
server = koa.server
|
2023-08-21 16:31:35 +02:00
|
|
|
// startup includes automation runner - if enabled
|
2024-04-05 13:14:51 +02:00
|
|
|
await startup({ app, server })
|
2023-08-17 17:39:25 +02:00
|
|
|
}
|
2020-12-04 13:09:02 +01:00
|
|
|
|
2023-08-17 17:39:25 +02:00
|
|
|
start().catch(err => {
|
|
|
|
console.error(`Failed server startup - ${err.message}`)
|
2024-02-16 16:13:26 +01:00
|
|
|
throw err
|
2020-12-04 13:09:02 +01:00
|
|
|
})
|
2022-08-31 11:47:41 +02:00
|
|
|
|
2024-02-28 11:08:42 +01:00
|
|
|
export function getServer(): Server {
|
2023-08-17 17:51:11 +02:00
|
|
|
return server
|
2023-08-17 17:39:25 +02:00
|
|
|
}
|