-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
53 lines (46 loc) · 1.24 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { logger, server } from "./src/server";
import fastifyCron from "fastify-cron";
import { cronLoadPropertyData } from "./src/server/cron/cron-get-property-listings";
import { cronLoadRentalListingsData } from "./src/server/cron/cron-get-rental-listings";
server.register(fastifyCron, {
jobs: [
cronLoadPropertyData,
// cronLoadRentalListingsData,
],
});
server.get("/health", (request, reply) => {
reply.send("OK");
});
server.get("/", (request, reply) => {
reply.send("OK");
});
const start = async () => {
try {
const port = 8080;
server.listen({ port }, () => {
logger.info(`Server running on port ${port}`);
if (server.cron) {
server.cron.startAllJobs();
}
});
} catch (err) {
logger.error("Errored while listening");
logger.error(err);
process.exit(1);
}
};
start();
process.on("uncaughtException", async (err) => {
logger.fatal("uncaughtException");
// windowManager.killWindows();
logger.error(err);
// await ChromeLauncher.killAll();
// process.exit(1);
});
process.on("unhandledRejection", async (err) => {
logger.fatal("unhandledRejection");
// windowManager.killWindows();
logger.error(err);
// await ChromeLauncher.killAll();
// process.exit(1);
});