The shutdown-check CLI has two commands. init creates a starter config.
test starts your service and verifies its behavior after SIGTERM.
Install and open the help
npm install -D shutdown-check
npx shutdown-check --helpThe installed help output is:
shutdown-check — verify graceful shutdown with a real in-flight HTTP request
Usage:
shutdown-check init [--config FILE]
shutdown-check test [--config FILE] [--json] [--junit FILE]
shutdown-check --help
shutdown-check --version
Default config: shutdown-check.json
Exit codes: 0 passed, 1 shutdown check failed, 2 setup/configuration errorRunning shutdown-check without arguments also prints the help.
Commands
| Command | What it does |
|---|---|
| init | Write a starter shutdown-check.json |
| test | Run the graceful shutdown check |
Create a config with init
npx shutdown-check initinit writes shutdown-check.json in the current directory.
| Option | What it does |
|---|---|
| --config FILE | Read (for `test`) or write (for `init`) this config file instead of `shutdown-check.json`. Paths in it resolve from the file's folder. |
Use --config to choose another path:
npx shutdown-check init --config config/shutdown-check.jsonThe command prints the created path and reminds you to edit the command, port,
and routes. It never overwrites a file. If the target exists, the CLI exits
with code 2:
shutdown-check: EEXIST: file already exists, open '/home/me/my-service/shutdown-check.json'Edit the existing file, rename it, or choose a different --config path. The
configuration reference explains every generated
field.
Run a check with test
npx shutdown-check testtest reads the config, starts the command, waits for readiness, creates
active work, sends SIGTERM, and checks the response and process exit.
| Option | What it does |
|---|---|
| --config FILE | Read (for `test`) or write (for `init`) this config file instead of `shutdown-check.json`. Paths in it resolve from the file's folder. |
| --json | Print the full result as JSON on stdout instead of the text timeline. |
| --junit FILE | Also write a JUnit XML report with one test case to this file. |
Common forms:
npx shutdown-check test
npx shutdown-check test --config config/shutdown-check.json
npx shutdown-check test --json
npx shutdown-check test --junit shutdown-result.xml
npx shutdown-check test --json --junit shutdown-result.xml--config FILE
Read a config from another path. Relative paths are resolved from the current
working directory. Inside the file, cwd is resolved from the config file's
folder.
--json
Replace the readable text output on stdout with the complete JSON result. This is useful for scripts and structured CI logs. It does not change the process exit code.
--junit FILE
Write a JUnit XML report in addition to text or JSON output. The parent folder must already exist. The file is written before the normal result is printed.
--json and --junit belong to test. Passing either to init is an unknown
option.
Help and version flags
| Flag | Short | Behavior |
|---|---|---|
--help | -h | Print help; it must be the first argument |
--version | -v | Print the installed version; no other argument is valid |
npx shutdown-check --versionHow is the config path resolved?
Without --config, the CLI reads shutdown-check.json from the directory
where you run the command.
With this layout:
my-service/
├── config/
│ └── shutdown-check.json
└── dist/
└── server.jsrun:
npx shutdown-check test --config config/shutdown-check.jsonThen use "cwd": ".." inside the config if the server command should run from
my-service/.
The CLI accepts JSON only. For a TypeScript config, use defineConfig() and
checkShutdown() from the Node API.
Text output
The default output contains:
PASSorFAIL, followed by a diagnostic code and message;- a timeline with milliseconds since the run began;
- on failure, the last 8 KiB of service stderr and stdout when present.
FAIL SC101: Service exited before becoming ready: code 1
Timeline:
+ 7 ms process launched — pid=74471
+ 47 ms process exited — code=1, signal=none
+ 111 ms check failed — SC101: Service exited before becoming ready: code 1
Service stderr (last 8 KiB):
Error: Cannot find module ./dist/server.jsStart with the code, then read the final successful timeline event. The diagnostic code pages give a cause and fix for each failure.
Errors before the test begins
Command-line and config errors start with shutdown-check:. They have no SC
code or timeline because the test did not run.
| Example message | What to change |
|---|---|
Unknown command "run". Run shutdown-check --help. | Use init or test |
Unknown option "--verbose". Run shutdown-check --help. | Remove the unsupported flag |
--config requires a file path | Add a path after --config |
--junit requires a file path | Add a path after --junit |
Cannot read JSON config /path/shutdown-check.json: Error: ENOENT: no such file or directory, open '/path/…' | Fix the path or create the file |
baseUrl must use http://localhost, http://127.0.0.1 or http://[::1] | Use a supported local origin |
See troubleshooting for configuration, startup, and shutdown failures grouped by symptom.
Exit codes
| Exit code | Meaning |
|---|---|
| 0 | passed |
| 1 | shutdown check failed |
| 2 | setup/configuration error |
0means the configured shutdown contract passed.1means the check ran and returned a failing SC code.2means invalid arguments, configuration, or setup stopped the check.
A code 1 run can still write JSON and JUnit. A code 2 run has no test
result, so it writes no JUnit report.
Other package managers
| npm | pnpm | Yarn | Bun |
|---|---|---|---|
npx shutdown-check test | pnpm exec shutdown-check test | yarn shutdown-check test | bunx shutdown-check test |
Each command runs the version installed in the current project.