Updated 16 Oct 2012, Andrew Kelley
naught is a node.js tool that solves some problems when running your node.js server in production. This article compares naught with forever to help you decide which tool to use.
$ time npm test > forever@0.10.1 test /home/andy/Downloads/forever > vows test/**/*-test.js --spec -i ♢ forever/core/tail When using forever the tail() method ✓ should respond with logs for the script When the tests are over stop all forever processes ✓ should stop the correct number of procs ♢ forever/service/simple When using forever the service module ✓ should have the correct exports ♢ forever/workers/multiple When using forever and spawning two processes using the same script ✓ should respond with no error When using forever and spawning two processes using the same script requests against the second child ✓ should respond with i know nodejitsu ✓ stop the child process When using forever and spawning two processes using the same script requests against the first child ✗ should respond with i know nodejitsu » actual expected ... ✓ stop the child process Once the stop attempt has been made ✓ the processes should be dead ♢ forever/worker/simple When using forever worker and starting it and pinging it worker should connect and respond to pings ✓ with pong When using forever worker and starting it and pinging it worker should connect and when queried for data ✓ it should respond with data When using forever worker and starting it and pinging it worker should connect and when asked to kill the process ✓ it should kill the process When using forever worker and starting it and pinging it worker should connect and when quickly sending data and disconnecting ✓ it should not crash the worker ✗ Broken » 12 honored ∙ 1 broken (3.531s) npm ERR! Test failed. See above for more details. npm ERR! not ok code 0 real 0m4.810s user 0m2.420s sys 0m0.320s
andy@andyba:~/dev/naught$ time npm test > naught@0.3.0 test /home/andy/dev/naught > node test/test.js (test setup) use server1.js...pass ability to start a server...pass starting a server twice prints the status of the running server...pass ability to query status of a running server...pass make sure the server is up...pass (test setup) use server2.js...pass ability to deploy to a running server...pass ability to change environment variables of workers...pass ability to stop a running server...pass stopping a server twice prints helpful output...pass redirect stdout to log file...pass redirect stderr to log file...pass naught log contains events...pass (test setup) rm naught.log stderr.log stdout.log server.js...pass (test setup) use server3.js...pass (test setup) mkdir foo...pass cli accepts non-default args...pass command line arguments passed to server correctly...pass multi-worker server responding to get requests...pass (test setup) generate log output...pass (test setup) generate log output...pass (test setup) generate log output...pass ability to stop a running server with multiple workers...pass log rotation and gzipping: naught log...pass log rotation and gzipping: stderr log...pass log rotation and gzipping: stdout log...pass (test setup) rm -rf foo log some server.js...pass (test setup) use server4.js...pass (test setup) starting a server that won't shut down...pass ability to stop a hanging server with a timeout...pass (test setup) rm naught.log stderr.log stdout.log server.js...pass (test setup) use server5.js...pass ability to pass command line arguments to node...pass make sure --harmony --use-strict worked...pass (test setup) stopping server...pass (test setup) rm naught.log stderr.log stdout.log server.js...pass 36 tests passed real 0m3.789s user 0m0.784s sys 0m0.092s
forever$ wc -l $(find . -name "*.js" -print) 845 ./lib/forever.js 519 ./lib/forever/cli.js 102 ./lib/forever/service/cli.js 267 ./lib/forever/service/service.js 22 ./lib/forever/service/index.js 95 ./lib/forever/service/adapters/adapter.js 8 ./lib/forever/service/adapters/initd/index.js 198 ./lib/forever/service/adapters/systemv/index.js 122 ./lib/forever/worker.js 2 ./test/fixtures/log-on-interval.js 16 ./test/fixtures/start-daemon.js 16 ./test/fixtures/server.js 73 ./test/worker/simple-test.js 98 ./test/worker/multiple-workers-test.js 54 ./test/core/tail-stopall-test.js 25 ./test/service/simple-test.js 93 ./test/helpers/macros.js 25 ./test/helpers/mocks/monitor.js 19 ./test/helpers/mocks/stream.js 12 ./test/helpers/mocks/child-process.js 2611 total
naught$ wc -l $(find . -name "*.js" -print) $(find . -name "*.co" -print) 15 ./test/server1.js 513 ./test/test.js 13 ./test/server2.js 16 ./test/server4.js 20 ./test/server5.js 44 ./test/server3.js 377 ./src/main.co 208 ./src/master.co 73 ./src/log.co 21 ./src/json_socket.co 118 ./src/daemon.co 1418 total
forever@0.10.0 node_modules/forever ├── watch@0.5.1 ├── timespan@2.0.1 ├── pkginfo@0.2.3 ├── optimist@0.3.4 (wordwrap@0.0.2) ├── utile@0.1.2 (deep-equal@0.0.0, rimraf@1.0.9, mkdirp@0.3.4, ncp@0.2.6, i@0.3.1) ├── cliff@0.1.8 (eyes@0.1.8, colors@0.6.0-1) ├── winston@0.6.2 (cycle@1.0.0, eyes@0.1.8, colors@0.6.0-1, stack-trace@0.0.6, request@2.9.203) ├── nssocket@0.3.8 (lazy@1.0.8, eventemitter2@0.4.10) ├── nconf@0.6.1 (ini@1.0.5) ├── flatiron@0.2.3 (director@1.1.0, broadway@0.2.3, prompt@0.2.2) └── forever-monitor@1.0.1 (minimatch@0.0.5, utile@0.0.10, ps-tree@0.0.2, broadway@0.2.5)
naught@0.3.0 node_modules/naught ├── async@0.1.23 └── mkdirp@0.3.4
Use naught. It's better.