Skip to content

Commit

Permalink
docs: make mention of graceful shutdown (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejose19 authored May 27, 2020
1 parent 49b4561 commit cf989be
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ And use these events to report the store's status.
- [koa-generic-session-sequelize](https://github.com/natesilva/koa-generic-session-sequelize) to store your session data with the [Sequelize](http://docs.sequelizejs.com/) ORM.
- [koa-generic-session-knex](https://github.com/EarthlingInteractive/koa-generic-session-knex) to store your session data with the [Knex](http://knexjs.org/) query builder.
## Graceful shutdown
Since this middleware comes with an auto-reconnect feature, it's very likely you can't gracefully shutdown after
closing the client as generic-session will try to recover the connection, in those cases you can disable reconnect feature (https://github.com/koajs/generic-session/blob/49b45612877d1a1b8a42dc61bfeba46b71f9cb52/src/session.js#L103-L112) desactivating the client emitter (do this only when stopping the server)
Example with ioredis
```js
// ...disconnecting from db
redisClient.emit = () => true;
await redisClient.quit();
// ...stopping the server
```
## Licences
(The MIT License)
Expand Down

1 comment on commit cf989be

@niftylettuce
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ejose19 yo might be interested in how I handled graceful shutdown with my work on https://lad.js.org and specifically https://github.com/ladjs/graceful

Please sign in to comment.