25 lines
644 B
TypeScript
25 lines
644 B
TypeScript
// src/worker.ts
|
|
|
|
import { run } from "graphile-worker";
|
|
import preset from '../graphile.config'
|
|
import logger from "./utils/logger";
|
|
|
|
|
|
async function main() {
|
|
// Run a worker to execute jobs:
|
|
const runner = await run({ preset });
|
|
|
|
// Immediately await (or otherwise handle) the resulting promise, to avoid
|
|
// "unhandled rejection" errors causing a process crash in the event of
|
|
// something going wrong.
|
|
await runner.promise;
|
|
|
|
// If the worker exits (whether through fatal error or otherwise), the above
|
|
// promise will resolve/reject.
|
|
}
|
|
|
|
main().catch((err) => {
|
|
logger.error(err);
|
|
process.exit(1);
|
|
});
|