Top Related Projects
Monitor for any changes in your node.js application and automatically restart the server - perfect for development
A simple CLI tool for ensuring that a given script runs continuously (i.e. forever)
Quick Overview
Node-supervisor is a tool for automatically restarting Node.js applications when file changes are detected in the directory. It's designed to improve the development workflow by eliminating the need to manually restart the server after making code changes.
Pros
- Automatically restarts the Node.js application when files are modified
- Supports watching specific file extensions
- Can run programs written in Node.js or Python
- Allows for ignoring specific files or directories
Cons
- Not actively maintained (last commit was in 2019)
- May conflict with built-in watch modes in modern Node.js frameworks
- Limited configuration options compared to more modern alternatives
- Potential performance overhead in large projects with frequent file changes
Code Examples
- Basic usage:
const supervisor = require('supervisor');
supervisor.run(['server.js']);
This code starts supervising the server.js
file, restarting it when changes are detected.
- Watching specific extensions:
const supervisor = require('supervisor');
supervisor.run(['-e', 'js,json', 'server.js']);
This example configures supervisor to watch only .js
and .json
files for changes.
- Ignoring specific directories:
const supervisor = require('supervisor');
supervisor.run(['--ignore', 'node_modules,test', 'server.js']);
This code tells supervisor to ignore changes in the node_modules
and test
directories.
Getting Started
To use node-supervisor in your project:
-
Install the package:
npm install supervisor
-
Run your Node.js application using supervisor:
supervisor server.js
-
For more options, use the help command:
supervisor -h
Node-supervisor will now monitor your application and restart it automatically when file changes are detected.
Competitor Comparisons
Monitor for any changes in your node.js application and automatically restart the server - perfect for development
Pros of nodemon
- More actively maintained with frequent updates
- Supports watching specific file types and custom extensions
- Offers a more extensive configuration options through nodemon.json
Cons of nodemon
- Slightly more complex setup for advanced use cases
- May consume more system resources in large projects
Code Comparison
nodemon:
{
"watch": ["src"],
"ext": "js,json",
"ignore": ["src/**/*.spec.js"],
"exec": "node ./src/index.js"
}
node-supervisor:
supervisor -w src -e js,json -i src/**/*.spec.js src/index.js
Key Differences
- nodemon provides a more flexible configuration system
- node-supervisor has a simpler command-line interface
- nodemon offers more granular control over file watching
- node-supervisor is lighter weight and may be preferable for simpler projects
Use Cases
nodemon is well-suited for:
- Complex Node.js applications with diverse file types
- Projects requiring detailed watch configurations
node-supervisor is ideal for:
- Quick setup in smaller projects
- Developers preferring a straightforward command-line tool
Both tools effectively auto-restart Node.js applications during development, but nodemon's active maintenance and extensive features make it a more popular choice for many developers.
A simple CLI tool for ensuring that a given script runs continuously (i.e. forever)
Pros of Forever
- More comprehensive process management with features like logging, clustering, and custom scripts
- Actively maintained with regular updates and a larger community
- Supports multiple programming languages, not just Node.js
Cons of Forever
- More complex setup and configuration compared to Supervisor
- Higher resource usage due to additional features
- Steeper learning curve for beginners
Code Comparison
Supervisor:
supervisor app.js
Forever:
forever start app.js
forever list
forever stop app.js
Key Differences
- Supervisor focuses on simplicity and ease of use for Node.js applications
- Forever offers more advanced features and flexibility for various types of applications
- Supervisor automatically restarts the application on file changes, while Forever requires manual restart or additional configuration
Use Cases
- Supervisor: Ideal for small to medium Node.js projects and development environments
- Forever: Better suited for production environments, complex applications, and multi-language projects
Community and Support
- Supervisor has a smaller but dedicated community
- Forever has a larger user base and more frequent updates
Performance
- Supervisor generally has lower resource overhead
- Forever may have slightly higher resource usage due to additional features
Both tools serve similar purposes but cater to different needs and preferences in the Node.js ecosystem.
Pros of node-supervisor
- Identical functionality and features
- Same codebase and implementation
Cons of node-supervisor
- No unique advantages over the compared repository
- Identical limitations and potential issues
Code Comparison
Both repositories contain the same codebase, so there are no differences to highlight. Here's a sample from both:
function crash_watcher() {
if (child && child.pid) {
setTimeout(function() {
if (child_status === KILLED) {
log("Program killed, restarting...");
run();
}
}, 750);
}
}
Summary
The comparison between node-supervisor and node-supervisor reveals that they are identical repositories. Both share the same codebase, functionality, and features. There are no distinguishing factors between them, as they appear to be exact copies or mirrors of each other. This situation makes it challenging to identify specific pros or cons for one over the other, as they essentially represent the same project.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
node-supervisor
A little supervisor script for nodejs. It runs your program, and
watches for code changes, so you can have hot-code reloading-ish
behavior, without worrying about memory leaks and making sure you
clean up all the inter-module references, and without a whole new
require
system.
node-supervisor -?
Node Supervisor is used to restart programs when they crash.
It can also be used to restart programs when a *.js file changes.
Usage:
supervisor [options] <program>
supervisor [options] -- <program> [args ...]
Required:
<program>
The program to run.
Options:
-w|--watch <watchItems>
A comma-delimited list of folders or js files to watch for changes.
When a change to a js file occurs, reload the program
Default is '.'
-i|--ignore <ignoreItems>
A comma-delimited list of folders to ignore for changes.
No default
--ignore-symlinks
Ignore symlinks :)
-s|--timestamp
Log timestamp after each run.
Make it easy to tell when the task last ran.
-p|--poll-interval <milliseconds>
How often to poll watched files for changes.
Defaults to Node default.
-e|--extensions <extensions>
A comma-delimited list of file extensions to watch for changes.
Default is 'node,js' (or when CoffeeScript, 'node,js,coffee,litcoffee').
-x|--exec <executable>
The executable that runs the specified program.
Default is 'node'
-pid|--save-pid <path>
Save supervisor's process id to a file at the given path.
--debug[=port]
Start node with --debug flag.
--debug-brk[=port]
Start node with --debug-brk flag.
--harmony
Start node with --harmony flag.
--inspect[=port]
Start node with --inspect flag.
-n|--no-restart-on error|exit|success
Don't automatically restart the supervised program if it ends.
Supervisor will wait for a change in the source files.
If "error", an exit code of 0 will still restart.
If "exit", no restart regardless of exit code.
If "success", no restart only if exit code is 0.
-t|--non-interactive
Dissable interactive capacity
With this option, supervisor won't listen to stdin
--force-watch
Use fs.watch instead of fs.watchFile.
This may be useful if you see a high cpu load on a windows machine.
-k|--instant-kill
Instantly kills the server process, instead of gracefully shutting down the server.
This can be useful when the node app has events attached to SIGTERM or SIGINT so as to do a graceful shutdown before the process exits.
-RV|--restart-verbose
Logs the file(s) that caused supervisor to restart
-h|--help|-?
Display these usage instructions.
-q|--quiet
Suppress DEBUG messages
Options available after start:
rs - restart process. Useful when you want to restart your program even
if no file has changed.
Examples:
supervisor myapp.js
supervisor myapp.coffee
supervisor -w scripts -e myext -x myrunner myapp
supervisor -w lib,server.js,config.js server.js
supervisor -- server.js -h host -p port
In order to not watch for file changes, use "-i .".
Simple Install
Just run:
npm install supervisor -g
Fancy Install
Get this code, and then do this:
npm link
Top Related Projects
Monitor for any changes in your node.js application and automatically restart the server - perfect for development
A simple CLI tool for ensuring that a given script runs continuously (i.e. forever)
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot