Gathering detailed insights and metrics for respawn
Gathering detailed insights and metrics for respawn
Gathering detailed insights and metrics for respawn
Gathering detailed insights and metrics for respawn
npm install respawn
Typescript
Module System
Node Version
NPM Version
76.2
Supply Chain
95.8
Quality
75.5
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
1,443,589
Last Day
74
Last Week
1,978
Last Month
8,888
Last Year
105,389
MIT License
255 Stars
90 Commits
34 Forks
9 Watchers
1 Branches
9 Contributors
Updated on Oct 27, 2024
Minified
Minified + Gzipped
Latest Version
2.6.0
Package Id
respawn@2.6.0
Size
5.20 kB
NPM Version
6.4.1
Node Version
10.15.0
Published on
Jan 14, 2019
Cumulative downloads
Total Downloads
Last Day
89.7%
74
Compared to previous day
Last Week
-3.3%
1,978
Compared to previous week
Last Month
-7.3%
8,888
Compared to previous month
Last Year
-37.1%
105,389
Compared to previous year
Spawn a process and restart it if it crashes.
npm install respawn
It is easy to use
1var respawn = require('respawn') 2 3var monitor = respawn(['node', 'server.js'], { 4 name: 'test', // set monitor name 5 env: {ENV_VAR:'test'}, // set env vars 6 cwd: '.', // set cwd 7 maxRestarts:10, // how many restarts are allowed within 60s 8 // or -1 for infinite restarts 9 sleep:1000, // time to sleep between restarts, 10 kill:30000, // wait 30s before force killing after stopping 11 stdio: [...], // forward stdio options 12 fork: true // fork instead of spawn 13}) 14 15monitor.start() // spawn and watch
Optionally you can specify the command to to spawn in the option map as command: [...]
Per default respawn will restart you app indefinitely. To set a max restart limit set the maxRestarts
option.
If sleep
is an array of numbers it will use the value at the position of the current number of restarts as the timeout value. If the number of restarts exceed the length of the array it will use the last value in the array until it hits the maxRestarts.
sleep: [1000, 60000, 60000, 12000, 1000]
will wait 1000ms before retrying, then it will wait 60000 before the next retry and so forth.
If sleep
is a function it will be passed the number of times (including this one) that the app has been restarted (i.e. first time will be called with 1, second time 2 etc.) and should return a time in milliseconds.
monitor.start()
Starts the monitor
monitor.stop(cb)
Stops the monitor (kills the process if its running with SIGTERM)
monitor.status
Get the current monitor status. Available values are running
, stopping
, stopped
, crashed
and sleeping
monitor.on('start')
The monitor has started
monitor.on('stop')
The monitor has fully stopped and the process is killed
monitor.on('crash')
The monitor has crashed (too many restarts or spawn error).
monitor.on('sleep')
monitor is sleeping
monitor.on('spawn', process)
New child process has been spawned
monitor.on('exit', code, signal)
child process has exited
monitor.on('stdout', data)
child process stdout has emitted data
monitor.on('stderr', data)
child process stderr has emitted data
monitor.on('warn', err)
child process has emitted an error
To do graceful restart simply have your app stop gracefully when receiving SIGTERM
and do
1// graceful restart (do not wait for old process to die) 2monitor.stop() 3monitor.start() 4 5// hard restart (wait for old process to die) 6monitor.stop(function() { 7 monitor.start() 8})
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 8/24 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-26
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More