Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
smart-restart
Advanced tools
Like nodemon but only watches require()d files. Like piping but easy to use with node-inspector.
nodemon
and piping
are great, but each has their limitations:
nodemon
sometimes restarts when you change files the server isn't using, which is a hassle when you're working on
isomorphic apps and just want a webpack hot update on the client.
piping
is difficult to use with node-inspector
because it runs a cluster; the supervisor process gets debug port 5858,
and your app process gets something else. It's even more of a pain to use with --debug-brk
because the supervisor
process starts with a breakpoint as well, so you have to open node-inspector
for it, resume it, then open
node-inspector
for your actual app.
smart-restart
combines both approaches: it uses piping
's require hook to only watch files that have been required,
but it spawns
your app instead of running a cluster, so that you can pass --debug
or --debug-brk
to your app.
To run ./src/index.js
in a child process and watch files it require
s:
var launch = require('smart-restart')
launch({
main: './src/index.js', // path to your script
command: 'node', // optional, the command to `spawn` (default: `process.argv[0]`)
commandOptions: ['--inspect'], // optional, arguments that come before `main`
args: [...], // optional, arguments that come after `main`
spawnOptions: {...}, // optional, options for `spawn`
onChildSpawned: child => {}, // optional, callback to receive ChildProcess instance
ignore: /(\/\.|~$)/, // optional, ignore pattern for `chokidar` (default: /(\/\.|~$)/)
usePolling: false, // optional, whether to use polling in `chokidar` (default: false)
interval: 100, // optional, polling interval for `chokidar` (default: 100)
binaryInterval: 300, // optional, binary polling interval for `chokidar` (default: 300)
includeModules: false, // optional, whether to include `node_modules` (default: false)
killSignal: 'SIGTERM', // optional, signal to kill process with when restarting
killTimeout: 5000, // optional, max amount of milliseconds to wait for process to get killed (default: 10000)
deleteRequireCache: [ // optional, when any files in this array (or files they require)
// are changed, all of these files will be deleted from `require.cache`
// instead of restarting the process.
'src/server/ssr/serverSideRender.js',
],
restartOnError: true, // optional, restart when child process has an uncaught error/promise rejection (default: true)
restartOnExit: true, // optional, restart when child process exits (default: true)
})
You can launch
as many other processes as you want in the same supervisor process.
You can process.send({exit: <code>})
to tell smart-restart
to exit
immediately instead of waiting to relaunch your process.
FAQs
Like nodemon but only watches require()d files. Like piping but easy to use with node-inspector.
The npm package smart-restart receives a total of 294 weekly downloads. As such, smart-restart popularity was classified as not popular.
We found that smart-restart demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.