2021-09-13 17:49:01 +07:00
|
|
|
import { createServer } from "http"
|
|
|
|
import { SERVER_PORT } from "./app.config"
|
2021-09-13 20:19:28 +07:00
|
|
|
import { info } from "@cubetiq/ts-common/dist/log"
|
2021-09-14 08:31:08 +07:00
|
|
|
import application from "./app/application"
|
2021-09-13 17:49:01 +07:00
|
|
|
|
|
|
|
// get current host id
|
|
|
|
const hostId = `${require("os").hostname()}#${process.pid}`
|
2021-09-13 17:57:27 +07:00
|
|
|
const startedAt = new Date()
|
2021-09-13 17:49:01 +07:00
|
|
|
|
2021-09-14 08:31:08 +07:00
|
|
|
const app = application.instance
|
2021-09-13 17:49:01 +07:00
|
|
|
const httpServer = createServer(app)
|
|
|
|
|
2021-09-13 20:19:28 +07:00
|
|
|
info(
|
2021-09-13 20:25:18 +07:00
|
|
|
`Application server running on: ${hostId} at: http://0.0.0.0:${SERVER_PORT} and started at: ${startedAt}`
|
2021-09-13 17:49:01 +07:00
|
|
|
)
|
|
|
|
httpServer.listen(SERVER_PORT)
|
|
|
|
|
2021-09-14 08:31:08 +07:00
|
|
|
app.get("/info", (req, res) => {
|
2021-09-13 17:49:01 +07:00
|
|
|
res.type("json")
|
|
|
|
res.send({
|
2021-09-13 17:57:27 +07:00
|
|
|
startedAt,
|
2021-09-13 17:49:01 +07:00
|
|
|
message: `Instance id: ${hostId}`,
|
|
|
|
status: "OK",
|
|
|
|
})
|
2021-09-13 20:19:28 +07:00
|
|
|
})
|