# @greenrenge/gracefully

> liveness and readiness wrapper using lightship for node.js

Latest version **2.0.4** (published 2026-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @greenrenge/gracefully
pnpm add @greenrenge/gracefully
yarn add @greenrenge/gracefully
bun add @greenrenge/gracefully
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2026-05-20 |
| First published | 2020-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 1 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kitthanat Srirussamee |
| Maintainers | greenrenge |
| Keywords | lightship, liveness, readiness, kubernetes, k8s, probes |

## Links

- npm: https://www.npmjs.com/package/@greenrenge/gracefully
- Repository: https://github.com/greenrenge/gracefully
- Homepage: https://github.com/greenrenge/gracefully#readme
- Issues: https://github.com/greenrenge/gracefully/issues
- npm.io page: https://npm.io/package/@greenrenge/gracefully

## Dependencies (1)

- [lightship](https://npm.io/package/lightship.md) ^9.0.4

## Recent versions

- 2.0.4 (latest) — 2026-05-20
- 2.0.3 — 2025-08-06
- 2.0.2 — 2025-07-30
- 2.0.1 — 2025-07-30
- 1.1.0 — 2020-12-09
- 1.0.0 — 2020-03-11

## README

# @greenrenge/gracefully

A lightship module for support kubernetes liveness and readiness

## Description

This module is a simple wrapper of the original [lightship](https://github.com/gajus/lightship#readme) library which helps to easily initialize the ready callback functions for multiple source of `ready` interconnected services being used by the application (eg. database) or configuration loading of the application.

## Features

- add `createReadiness` which help to split lightship `signalReady` to multiple functions
- server exposes on paths `/health` `/live` and `/ready` as the original lightship does but listen on port `13000` by default
- add `enableLog` option to print lightship logs
- add `randomPortOnLocal` to reserve random port behavior when the process is run on local as the original lightship does, default to `false`

## Install

```sh
npm install --save @greenrenge/gracefully
```

## Usage

#### Readiness

```javascript
import createLightship from "@greenrenge/gracefully"

const { createReadiness } = await createLightship()
const [mongooseDbReady, expressReady, senecaReady] = createReadiness(3)

// for mongoose connection
mongoose.connect(/* connectionString */)
mongoose.connection.on("connected", () => mongooseDbReady())

// for express
const app = express()
app.listen(3000, () => expressReady())

// for seneca
require("seneca")({ some_options: 123 })
  .use("community-plugin-1", { some_config: SOME_CONFIG })
  .use("community-plugin-2")
  .listen(/* ... */)
  .client(/* ... */)
  .ready(() => senecaReady())
```

in case of making service back to not ready state, we get functions by 2 ways ..

```javascript
const [mongooseDbReady] = createReadiness()

// first way, return from ready function call
const mongooseNotReady = mongooseDbReady()
mongooseNotReady()

// second way, by property `toNotReady` of ready function
mongooseDbReady.toNotReady()
```

## License

MIT © [Greenrenge](https://github.com/greenrenge)

---
_Source: https://npm.io/package/@greenrenge/gracefully · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
