README
@fastify/restartable
Restart Fastify without losing a request.
This module is useful if you want to compose the fastify routes dynamically or you need some remote config. In case of a change, you can restart Fastify.
Install
npm i @fastify/restartable
Usage
import { start } from '@fastify/restartable'
async function myApp (app, opts) {
// opts are the options passed to start()
console.log('plugin loaded', opts)
app.get('/restart', async (req, reply) => {
await app.restart()
return { status: 'ok' }
})
}
const { stop, port, restart, address } = await start({
protocol: 'http', // or 'https'
// key: ...,
// cert: ...,
// add all other options that you would pass to fastify
host: '127.0.0.1',
port: 3000,
app: myApp
})
console.log('server listening on', address, port)
// call restart() if you want to restart
License
MIT