-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevelop.js
More file actions
30 lines (25 loc) · 836 Bytes
/
develop.js
File metadata and controls
30 lines (25 loc) · 836 Bytes
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
/**
* Our GraphQL service
*/
const { server, httpServer, app } = require("./api/graphql.js");
server.start().then(async () => {
server.applyMiddleware({ app, path: "/.netlify/functions/graphql" });
httpServer.listen({ port: 8081, host: "0.0.0.0" });
console.log("😺 Local server running! http://localhost:8080");
});
/**
* Recurring tasks and workers
*/
const { CronJob } = require("cron");
const { handler: minuteWorker } = require("./api/worker");
const minuteWorkerJob = new CronJob("* * * * *", minuteWorker);
console.log("Starting recurring tasks");
minuteWorkerJob.start();
const killTasks = () => {
process.stdout.write("Stopping recurring tasks");
minuteWorkerJob.stop();
};
process.on("SIGINT", killTasks);
process.on("SIGABRT", killTasks);
process.on("SIGTERM", killTasks);
process.on("exit", killTasks);