import { dirname, extname, join } from 'node:path'
+import { exit } from 'node:process'
import { fileURLToPath } from 'node:url'
+
import Fastify from 'fastify'
+
import { fastifyPoolifier } from './fastify-poolifier.js'
/**
const port = 8080
const fastify = Fastify({
- logger: true
+ logger: true,
})
const workerFile = join(
dirname(fileURLToPath(import.meta.url)),
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`worker${extname(fileURLToPath(import.meta.url))}`
)
workerFile,
enableTasksQueue: true,
tasksQueueOptions: {
- concurrency: 8
+ concurrency: 8,
},
errorHandler: (e: Error) => {
- fastify.log.error(e)
- }
+ fastify.log.error('Thread worker error:', e)
+ },
})
fastify.all('/api/echo', async request => {
await fastify.listen({ port })
} catch (err) {
fastify.log.error(err)
- process.exit(1)
+ exit(1)
}