From c7149cffad197b52837e5b7457028932e566ad99 Mon Sep 17 00:00:00 2001 From: apetitco Date: Thu, 4 Dec 2025 15:05:49 +0100 Subject: [PATCH] (misc): Started working on entrypoint for the microservice. --- src/tic-tac-toe/src/run.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/tic-tac-toe/src/run.ts diff --git a/src/tic-tac-toe/src/run.ts b/src/tic-tac-toe/src/run.ts new file mode 100644 index 0000000..2b8a619 --- /dev/null +++ b/src/tic-tac-toe/src/run.ts @@ -0,0 +1,30 @@ +// @file run.ts + +// Entry point of the microservice, ran by the Dockerfile. + +import fastify, { FastifyInstance } from 'fastify'; +// TODO: Import the microservice app + + +// @brief Entrypoint for the microservice's backend. +const start = async () => { + // TODO: Thingies to send to log service (if I understood that correctly from /src/chat/src/run.ts) + + // TODO: Add the logging thingy to the call to fastify() + const fastInst: FastifyInstance = fastify(); + try { + process.on('SIGTERM', () => { + fastInst.log.info('Requested to shutdown'); + process.exit(143); + }); + // TODO: Uncomment when app.ts will be import-able. + // await fastInst.register(app); + await fastInst.listen({ port: 80, host: '0.0.0.0' }); + } + catch (err) { + fastInst.log.error(err); + process.exit(1); + }; +}; + +start(); \ No newline at end of file