Skip to content

Commit 7b5534c

Browse files
committed
Update readme with information regarding shutdown
1 parent 5388e7b commit 7b5534c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Readme.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ This module provides access to an Oracle database connection pool via the
55
[oracledb](https://npm.im/oracledb) module. It decorates the [Fastify](https://fastify.io)
66
instance with an `oracle` property that is a connection pool instance.
77

8-
When the Fastify server is shutdown, this plugin invokes the `.close()` on the
9-
connection pool.
8+
When the Fastify server is shutdown, this plugin invokes the `.close()` method
9+
on the connection pool.
1010

1111
## Example
1212

@@ -27,6 +27,19 @@ fastify.get('/db_data', async function (req, reply) {
2727
await conn.close()
2828
return results
2929
})
30+
31+
fastify.listen(3000, (err) => {
32+
if (err) {
33+
fastify.log.error(err)
34+
// Manually close since Fastify did not boot correctly.
35+
fastify.oracle.close()
36+
process.exit(1)
37+
}
38+
39+
// Initiate Fastify's shutdown procedure so that the plugin will
40+
// automatically close the connection pool.
41+
process.on('SIGTERM', fastify.close.bind(fastify))
42+
})
3043
```
3144

3245
## Options

0 commit comments

Comments
 (0)