Skip to content
Browse files

first commit

  • Loading branch information...
0 parents commit 236944041b15ce2c4252be5ad80e57f96937425d @caolan committed
Showing with 10,300 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +11 −0 INSTALL
  3. +38 −0 bin/jambot
  4. +13 −0 config.example
  5. +66 −0 lib/bot.js
  6. +73 −0 lib/irc.js
  7. +131 −0 lib/logger.js
  8. +1 −0 node_modules/.bin/follow
  9. +1 −0 node_modules/.bin/forever
  10. +1 −0 node_modules/.bin/foreverd
  11. +6 −0 node_modules/forever/.npmignore
  12. +138 −0 node_modules/forever/CHANGELOG.md
  13. +19 −0 node_modules/forever/LICENSE
  14. +241 −0 node_modules/forever/README.md
  15. +20 −0 node_modules/forever/bin/forever
  16. +4 −0 node_modules/forever/bin/foreverd
  17. +194 −0 node_modules/forever/docs/docco.css
  18. +608 −0 node_modules/forever/docs/forever.html
  19. +289 −0 node_modules/forever/docs/forever/cli.html
  20. +274 −0 node_modules/forever/docs/forever/monitor.html
  21. +1 −0 node_modules/forever/examples/all-env-vars.js
  22. +1 −0 node_modules/forever/examples/always-throw.js
  23. +14 −0 node_modules/forever/examples/chroot.js
  24. +4 −0 node_modules/forever/examples/cli-multiple-start
  25. +8 −0 node_modules/forever/examples/count-timer.js
  26. +1 −0 node_modules/forever/examples/custom-cwd.js
  27. +7 −0 node_modules/forever/examples/env-server.js
  28. +4 −0 node_modules/forever/examples/env-vars.js
  29. +6 −0 node_modules/forever/examples/error-on-timer.js
  30. +95 −0 node_modules/forever/examples/initd-example
  31. +37 −0 node_modules/forever/examples/list-multiple.js
  32. +3 −0 node_modules/forever/examples/log-on-interval.js
  33. +12 −0 node_modules/forever/examples/multiple-processes.js
  34. +6 −0 node_modules/forever/examples/process-send.js
  35. +16 −0 node_modules/forever/examples/server.js
  36. +8 −0 node_modules/forever/examples/signal-ignore.js
  37. +18 −0 node_modules/forever/examples/spawn-and-error.js
  38. +850 −0 node_modules/forever/lib/forever.js
  39. +522 −0 node_modules/forever/lib/forever/cli.js
  40. +400 −0 node_modules/forever/lib/forever/monitor.js
  41. +63 −0 node_modules/forever/lib/forever/plugins/logger.js
  42. +58 −0 node_modules/forever/lib/forever/plugins/watch.js
  43. +96 −0 node_modules/forever/lib/forever/service/adapters/adapter.js
  44. +9 −0 node_modules/forever/lib/forever/service/adapters/initd/index.js
  45. +82 −0 node_modules/forever/lib/forever/service/adapters/systemv/foreverd
  46. +199 −0 node_modules/forever/lib/forever/service/adapters/systemv/index.js
  47. +102 −0 node_modules/forever/lib/forever/service/cli.js
  48. +22 −0 node_modules/forever/lib/forever/service/index.js
  49. +276 −0 node_modules/forever/lib/forever/service/service.js
  50. +123 −0 node_modules/forever/lib/forever/worker.js
  51. +1 −0 node_modules/forever/node_modules/.bin/flatiron
  52. +4 −0 node_modules/forever/node_modules/broadway/.npmignore
  53. +14 −0 node_modules/forever/node_modules/broadway/.travis.yml
  54. +19 −0 node_modules/forever/node_modules/broadway/LICENSE
  55. +124 −0 node_modules/forever/node_modules/broadway/README.md
  56. +66 −0 node_modules/forever/node_modules/broadway/bin/build
  57. +12 −0 node_modules/forever/node_modules/broadway/examples/browser/app.js
  58. +11 −0 node_modules/forever/node_modules/broadway/examples/browser/index.html
  59. +23 −0 node_modules/forever/node_modules/broadway/examples/browser/plugins/helloworld.js
  60. +13 −0 node_modules/forever/node_modules/broadway/examples/nodejs/app.js
  61. +23 −0 node_modules/forever/node_modules/broadway/examples/nodejs/plugins/helloworld.js
  62. +19 −0 node_modules/forever/node_modules/broadway/lib/broadway.js
  63. +214 −0 node_modules/forever/node_modules/broadway/lib/broadway/app.js
  64. +53 −0 node_modules/forever/node_modules/broadway/lib/broadway/bootstrapper.js
  65. +75 −0 node_modules/forever/node_modules/broadway/lib/broadway/browser.js
  66. +78 −0 node_modules/forever/node_modules/broadway/lib/broadway/common/directories.js
  67. +18 −0 node_modules/forever/node_modules/broadway/lib/broadway/common/index.js
  68. +48 −0 node_modules/forever/node_modules/broadway/lib/broadway/features/index.js
  69. +49 −0 node_modules/forever/node_modules/broadway/lib/broadway/plugins/directories.js
  70. +70 −0 node_modules/forever/node_modules/broadway/lib/broadway/plugins/exceptions.js
  71. +40 −0 node_modules/forever/node_modules/broadway/lib/broadway/plugins/inspect.js
  72. +196 −0 node_modules/forever/node_modules/broadway/lib/broadway/plugins/log.js
  73. +2 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/.npmignore
  74. +19 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/LICENSE
  75. +227 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/README.md
  76. BIN node_modules/forever/node_modules/broadway/node_modules/cliff/assets/inspect.png
  77. BIN node_modules/forever/node_modules/broadway/node_modules/cliff/assets/put-object-rows.png
  78. BIN node_modules/forever/node_modules/broadway/node_modules/cliff/assets/put-object.png
  79. BIN node_modules/forever/node_modules/broadway/node_modules/cliff/assets/put-rows-colors.png
  80. BIN node_modules/forever/node_modules/broadway/node_modules/cliff/assets/put-rows.png
  81. BIN node_modules/forever/node_modules/broadway/node_modules/cliff/assets/string-object-rows.png
  82. BIN node_modules/forever/node_modules/broadway/node_modules/cliff/assets/string-rows.png
  83. +24 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/examples/inspect.js
  84. +23 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/examples/put-object-rows.js
  85. +24 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/examples/put-object.js
  86. +12 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/examples/put-rows-colors.js
  87. +11 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/examples/put-rows.js
  88. +23 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/examples/string-object-rows.js
  89. +11 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/examples/string-rows.js
  90. +279 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/lib/cliff.js
  91. +20 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/node_modules/eyes/LICENSE
  92. +4 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/node_modules/eyes/Makefile
  93. +72 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/node_modules/eyes/README.md
  94. +236 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/node_modules/eyes/lib/eyes.js
  95. +49 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/node_modules/eyes/package.json
  96. +56 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/node_modules/eyes/test/eyes-test.js
  97. +48 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/package.json
  98. +79 −0 node_modules/forever/node_modules/broadway/node_modules/cliff/test/cliff-test.js
  99. +22 −0 node_modules/forever/node_modules/broadway/node_modules/colors/MIT-LICENSE.txt
  100. +77 −0 node_modules/forever/node_modules/broadway/node_modules/colors/ReadMe.md
  101. +269 −0 node_modules/forever/node_modules/broadway/node_modules/colors/colors.js
  102. +74 −0 node_modules/forever/node_modules/broadway/node_modules/colors/example.html
  103. +65 −0 node_modules/forever/node_modules/broadway/node_modules/colors/example.js
  104. +33 −0 node_modules/forever/node_modules/broadway/node_modules/colors/package.json
  105. +65 −0 node_modules/forever/node_modules/broadway/node_modules/colors/test.js
  106. +13 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/.npmignore
  107. +203 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/README.md
  108. +1 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/index.js
  109. +547 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/lib/eventemitter2.js
  110. +82 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/package.json
  111. +123 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/test/common.js
  112. +53 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/test/perf/benchmark.js
  113. +192 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/test/simple/addListener.js
  114. +153 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/test/simple/emit.js
  115. +199 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/test/simple/removeListener.js
  116. +133 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/test/simple/setMax.js
  117. +126 −0 node_modules/forever/node_modules/broadway/node_modules/eventemitter2/test/simple/ttl.js
  118. +307 −0 ...dules/forever/node_modules/broadway/node_modules/eventemitter2/test/wildcardEvents/addListener.js
Sorry, we could not display the entire diff because too many files (1,042) changed.
3 .gitignore
@@ -0,0 +1,3 @@
+config.js
+log/*
+jambot.pid
11 INSTALL
@@ -0,0 +1,11 @@
+ArchLinux
+==========
+
+Add user 'jambot'
+
+To start as a daemon at boot:
+
+ln -s /path/to/jambot/rc.d/jambot /etc/rc.d/jambot
+ln -s /run/daemons/jambot /path/to/jambot/bin/jambot
+
+Edit /etc/rc.conf and add jambot to DAEMONS
38 bin/jambot
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+SOURCE="${BASH_SOURCE[0]}"
+while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
+DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+
+PIDFILE="$DIR/../jambot.pid"
+LOGFILE="$DIR/../log/jambot.log"
+OUTFILE="$DIR/../log/jambot.stdout"
+ERRFILE="$DIR/../log/jambot.stderr"
+
+mkdir -p "$DIR/../log"
+
+FOREVER="$(realpath $DIR/../node_modules/forever/bin/forever) --pidFile $PIDFILE -l $LOGFILE -o $OUTFILE -e $ERRFILE --append"
+
+BOT="$(realpath $DIR/../lib/bot.js)"
+
+case "$1" in
+ "start")
+ $FOREVER "start" $BOT
+ ;;
+ "stop")
+ $FOREVER "stop" $BOT
+ ;;
+ "restart")
+ $FOREVER "restart" $BOT
+ ;;
+ "fg")
+ node $BOT
+ ;;
+ *)
+ if [ -n "$1" ]; then
+ echo "Unknown command: $1"
+ fi
+ echo "Usage: $0 start|stop|restart|fg"
+ exit 1
+ ;;
+esac
13 config.example
@@ -0,0 +1,13 @@
+exports.irc = {
+ nick: 'bot',
+ server: 'irc.freenode.net',
+ channels: ['#mychannel']
+};
+
+exports.logger = {
+ level: 'info'
+};
+
+exports['jam-repository'] = {
+ db: 'http://groundcomputing.co.uk/code/jam/repository'
+};
66 lib/bot.js
@@ -0,0 +1,66 @@
+#!/usr/bin/env node
+
+process.title = 'jambot';
+
+
+var path = require('path'),
+ events = require('events'),
+ config = require('../config'),
+ logger = require('./logger'),
+ irc = require('./irc');
+
+
+logger.level = config.log_level || logger.level;
+
+
+// event emitter instance global to all plugins
+var ev = new events.EventEmitter();
+
+// instance passed to plugin
+function Bot(plugin) {
+ this.plugin = plugin;
+ this.config = config;
+ this.ev = ev;
+}
+Bot.prototype.emit = function () {
+ ev.emit.apply(ev, arguments);
+};
+Bot.prototype.on = function () {
+ ev.on.apply(ev, arguments);
+};
+Bot.prototype.error = function (err) {
+ logger.error(this.plugin, err);
+ this.emit('error', this.plugin, err);
+};
+Bot.prototype.info = function (err) {
+ logger.info(this.plugin, err);
+ this.emit('info', this.plugin, err);
+};
+Bot.prototype.debug = function (err) {
+ logger.debug(this.plugin, err);
+ this.emit('debug', this.plugin, err);
+};
+Bot.prototype.warning = function (err) {
+ logger.warning(this.plugin, err);
+ this.emit('warning', this.plugin, err);
+};
+Bot.prototype.say = function (to, msg) {
+ this.emit('say', to, msg);
+};
+
+
+// load basic services
+irc.init(new Bot('irc'));
+
+if (config.plugins) {
+ // load plugins
+ for (var name in config.plugins) {
+ var module = require(
+ path.resolve(__dirname, '..', config.plugins[name])
+ );
+ module.init(new Bot(name));
+ }
+}
+else {
+ logger.warning('No plugins loaded');
+}
73 lib/irc.js
@@ -0,0 +1,73 @@
+var irc = require('irc');
+
+
+exports.init = function (bot) {
+ var server = bot.config.irc.server;
+ var nick = bot.config.irc.nick;
+ var client = new irc.Client(server, nick, bot.config.irc);
+
+ bot.on('say', function (to, message) {
+ if (message === undefined) {
+ message = to;
+ to = bot.config.irc.channels;
+ }
+ if (Array.isArray(to)) {
+ to.forEach(function (t) {
+ bot.debug('saying to ' + t + ': ' + message);
+ client.say(t, message);
+ bot.emit('irc::say', nick, t, message);
+ });
+ }
+ else {
+ bot.debug('saying to ' + to + ': ' + message);
+ client.say(to, message);
+ bot.emit('irc::say', nick, to, message);
+ }
+ });
+
+ client.on('message', function (from, to, message) {
+ bot.debug(from + ' => ' + to + ': ' + message);
+ bot.emit('irc::message', from, to, message);
+ // TODO: if starts with nick: then bot.emit('msg', ...)
+ // and add bot.respond(regex, callback) method
+ });
+ client.on('topic', function (channel, topic, by) {
+ bot.debug('topic changed in ' + channel + ' by ' + by + ': ' + topic);
+ bot.emit('irc::topic', channel, topic, by);
+ });
+ client.on('join', function (channel, who) {
+ if (who === nick) {
+ bot.info('joined ' + channel);
+ }
+ else {
+ bot.debug(who + ' joined ' + channel);
+ }
+ bot.emit('irc::join', channel, who);
+ });
+ client.on('part', function (channel, who, reason) {
+ bot.debug(who + ' left ' + channel);
+ bot.emit('irc::part', channel, who, reason);
+ });
+ client.on('kick', function (channel, who, by, reason) {
+ bot.debug(by + ' kicked ' + who + ' from ' + channel + ': ' + reason);
+ bot.emit('irc::kick', channel, who, by, reason);
+ });
+ client.on('quit', function (who, reason, channels) {
+ bot.debug(who + ' quit');
+ bot.emit('irc::quit', who, reason, channels);
+ });
+ client.on('pm', function (from, message) {
+ bot.info('pm from: ' + from + ': ' + message);
+ bot.emit('irc::pm', from, message);
+ });
+ client.on('connect', function () {
+ bot.info('connected to ' + server + ' as ' + nick);
+ bot.emit('irc::connect', server, nick);
+ });
+ client.on('error', function (message) {
+ bot.error(message);
+ });
+ client.on('registered', function (message) {
+ bot.info('registered');
+ });
+};
131 lib/logger.js
@@ -0,0 +1,131 @@
+/**
+ * Module dependencies
+ */
+
+var util = require('util');
+
+/**
+ * The level to log at, change this to alter the global logging level.
+ * Possible options are: error, warning, info, debug. Default level is info.
+ */
+exports.level = 'info';
+
+
+/**
+ * Wraps some ANSI codes around some text.
+ */
+var wrap = function (code, reset) {
+ return function (str) {
+ return "\x1B[" + code + "m" + str + "\x1B[" + reset + "m";
+ };
+};
+
+/**
+ * ANSI colors and styles used by the logger module.
+ */
+var bold = exports.bold = wrap(1, 22);
+var red = exports.red = wrap(31, 39);
+var green = exports.green = wrap(32, 39);
+var cyan = exports.cyan = wrap(36, 39);
+var yellow = exports.yellow = wrap(33, 39);
+var magenta = exports.magenta = wrap(35, 39);
+
+/**
+ * Executes a function only if the current log level is in the levels list
+ *
+ * @param {Array} levels
+ * @param {Function} fn
+ */
+
+var forLevels = function (levels, fn) {
+ return function (label, val) {
+ for (var i = 0; i < levels.length; i++) {
+ if (levels[i] === exports.level) {
+ return fn(label, val);
+ }
+ }
+ };
+};
+
+/**
+ * Logs debug messages, using util.inspect to show the properties of objects
+ * (logged for 'debug' level only)
+ */
+
+exports.debug = forLevels(['debug'], function (label, val) {
+ if (val === undefined) {
+ val = label;
+ label = null;
+ }
+ if (typeof val !== 'string') {
+ val = util.inspect(val);
+ }
+ if (label && val) {
+ console.log(magenta(label + ' ') + val);
+ }
+ else {
+ console.log(label);
+ }
+});
+
+/**
+ * Logs info messages (logged for 'info' and 'debug' levels)
+ */
+
+exports.info = forLevels(['info', 'debug'], function (label, val) {
+ if (val === undefined) {
+ val = label;
+ label = null;
+ }
+ if (typeof val !== 'string') {
+ val = util.inspect(val);
+ }
+ if (label) {
+ console.log(cyan(label + ' ') + val);
+ }
+ else {
+ console.log(val);
+ }
+});
+
+/**
+ * Logs warnings messages (logged for 'warning', 'info' and 'debug' levels)
+ */
+
+exports.warning = forLevels(['warning', 'info', 'debug'], function (msg) {
+ console.log(yellow(bold('Warning: ') + msg));
+});
+
+/**
+ * Logs error messages (always logged)
+ */
+
+exports.error = function (err) {
+ var msg = err.message || err.error || err;
+ if (err.stack) {
+ msg = err.stack.replace(/^Error: /, '');
+ }
+ console.log(red(bold('Error: ') + msg));
+};
+
+
+/**
+ * Display a failure message if exit is unexpected.
+ */
+
+exports.clean_exit = false;
+exports.end = function (msg) {
+ exports.clean_exit = true;
+ exports.success(msg);
+};
+exports.success = function (msg) {
+ console.log(green(bold('OK') + (msg ? bold(': ') + msg: '')));
+};
+
+/**
+ * Log uncaught exceptions in the same style as normal errors.
+ */
+
+process.on('uncaughtException', function (err) {
+ exports.error(err.stack || err);
+});
1 node_modules/.bin/follow
1 node_modules/.bin/forever
1 node_modules/.bin/foreverd
6 node_modules/forever/.npmignore
@@ -0,0 +1,6 @@
+test/*.log
+node_modules/
+node_modules/*
+npm-debug.log
+.*.sw[op]
+test/fixtures/*.log
138 node_modules/forever/CHANGELOG.md
@@ -0,0 +1,138 @@
+## CHANGELOG
+
+### Version 0.7.0
+
+- Added experimental foreverd implementation for working with init.d, systemv, etc
+- Expose `Monitor.killTree` for killing process trees for processes spawned by forever (default: true)
+- Added commands for working with forever log files
+- Added forever.tail()
+- Update daemon to 0.3.2
+- Expose Monitor.spawnWith in Monitor.data
+
+### Version 0.6.9
+
+- Add `--plain` option disabling CLI colors
+
+### Version 0.6.8
+
+- Add --watch/-w command line option
+- Add implementation to restart processes when a file changes
+
+### Version 0.6.7
+
+- Replace sys module usages with util
+- Update winston dependency to 0.4.x
+
+### Version 0.6.6
+
+- Add options.hideEnv to hide default env values
+
+### Version 0.6.5
+
+- Update `forever.Monitor.prototype.restart()` to allow force restarting of processes in less than `.minUptime`
+
+### Version 0.6.4
+
+- Update forever.startServer() to support more liberal arguments.
+
+### Version 0.6.3
+
+- Create `sockPath` if it does not exist already.
+- When stopping only respond with those processes which have been stopped.
+
+### Version 0.6.2
+
+- Display warning / error messages to the user when contacting UNIX sockets.
+
+### Version 0.6.1
+
+- Fixed a bug where numbers in the file path caused forever to think
+- Process variables are not always available, for example if you execute
+
+### Version 0.6.0
+
+- Dont allow `-` in uuids generated by forever.
+- When executing stopall, dont kill the current process.
+- Added forever.debug for debugging purposes
+- Keep processes silent on `forever restart` if requested. A couple of minor log formatting updates
+- Update `forever list` to use cliff
+- Added generic hooks for forever.Monitor
+- Use default values for log file and pid file (prevents a process from being nuked by being daemonized)
+- Default `minUptime` to 0
+- Create `options.uid` by default in `.startDaemon()` if it is already not provided
+- Include uids in `forever list`
+- Catch `uncaughtException` slightly more intelligently
+- Forever no longer uses *.fvr files in-favor of a TCP server in each forever process started by the CLI. Programmatic usage will require an additional call to `forever.createServer()` explicitally in order for your application to be available in `forever list` or `forever.list()`
+- Add `portfinder` dependency to package.json
+- Expose `forever.columns` and update `forever.format` to generate results dynamically
+
+### Version 0.5.6
+
+- Update winston dependency to 0.3.x
+
+### Version 0.5.5
+
+- Remove .fvr file when a forever.Monitor child exits
+
+### Version 0.5.4
+
+- Add --spinSleepTime to throttle instead of killing spinning scripts
+
+### Version 0.5.3
+
+- Added `preferGlobal` option to package.json
+- Improve forever when working with `-c` or `--command`
+
+### Version 0.5.2
+
+- Print help when a valid action isn't given
+- Batch the cleaning of *.fvr and *.pid files to avoid file descriptor overload
+- Check if processes exist before returning in `.findByScript()`.
+
+### Version 0.5.1
+
+- Readd eyes dependency
+
+### Version 0.5.0
+
+- Added forever.logFilePath utility.
+- Added forever.pidFilePath implementation
+- Added append log implementation to CLI
+- Fix for spawning multiple processes from a single forever process
+- Added forever.config using nconf
+- Better bookkeeping of *.fvr and *.pid files
+
+### Version 0.4.1
+
+- Remove unnecessary eyes dependency
+
+### Version 0.4.1
+
+- Update sourceDir option to check for file paths relative to root
+
+### Version 0.4.0
+
+- Enable forever to track uptime
+- Add `restart` command to forever.Monitor and CLI
+- Ensure forever.load() is called on require()
+- Better handling for for `-p` CLI option
+- Enable options to be passed to child_process.spawn
+
+### Version 0.3.1
+
+- Allow forever to start any script (not just node) from nodejs code
+- Array shortcut to set command and options
+- Check for scripts with fs.stat before running them
+- Improved how *.fvr and *.pid files are managed by Forever CLI
+- Ability to delete all historical logs from CLI via 'cleanlogs'
+- Ability to stop script by name -- stops ALL scripts with that name.
+- Display logfile in 'forever list'.
+- Use process.kill() instead of exec('kill').
+- Emit 'save' event when persisting to disk.
+- Emit 'start' event when starting a forever child
+- Remove 'auto-save' feature from Forever.start()
+
+#### Breaking Changes
+
+- Push options hierarchy up one level. e.g. Forever.options.silent is now Forever.silent
+- Only 'error' event now emits with an error. All other events simply emit data
19 node_modules/forever/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2010 Nodejitsu Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
241 node_modules/forever/README.md
@@ -0,0 +1,241 @@
+# forever
+
+A simple CLI tool for ensuring that a given script runs continuously (i.e. forever).
+
+## Installation
+
+### Installing npm (node package manager)
+``` bash
+ curl http://npmjs.org/install.sh | sh
+```
+
+### Installing forever
+``` bash
+ $ [sudo] npm install forever -g
+```
+
+**Note:** If you are using forever _programatically_ you should not install it globally.
+
+``` bash
+ $ cd /path/to/your/project
+ $ [sudo] npm install forever
+```
+
+## Usage
+There are two distinct ways to use forever: through the command line interface, or by requiring the forever module in your own code.
+
+### Using forever from the command line
+You can use forever to run any kind of script continuously (whether it is written in node.js or not). The usage options are simple:
+
+```
+ $ forever --help
+ usage: forever [options] [action] SCRIPT [script-options]
+
+ Monitors the script specified in the current process or as a daemon
+
+ actions:
+ start Start SCRIPT as a daemon
+ stop Stop the daemon SCRIPT
+ stopall Stop all running forever scripts
+ restart Restart the daemon SCRIPT
+ restartall Restart all running forever scripts
+ list List all running forever scripts
+ config Lists all forever user configuration
+ set <key> <val> Sets the specified forever config <key>
+ clear <key> Clears the specified forever config <key>
+ logs Lists log files for all forever processes
+ logs <script|index> Tails the logs for <script|index>
+ columns add <col> Adds the specified column to the output in `forever list`
+ columns rm <col> Removed the specified column from the output in `forever list`
+ columns set <cols> Set all columns for the output in `forever list`
+ cleanlogs [CAREFUL] Deletes all historical forever log files
+
+ options:
+ -m MAX Only run the specified script MAX times
+ -l LOGFILE Logs the forever output to LOGFILE
+ -o OUTFILE Logs stdout from child script to OUTFILE
+ -e ERRFILE Logs stderr from child script to ERRFILE
+ -p PATH Base path for all forever related files (pid files, etc.)
+ -c COMMAND COMMAND to execute (defaults to node)
+ -a, --append Append logs
+ --pidFile The pid file
+ --sourceDir The source directory for which SCRIPT is relative to
+ --minUptime Minimum uptime (millis) for a script to not be considered "spinning"
+ --spinSleepTime Time to wait (millis) between launches of a spinning script.
+ --plain Disable command line colors
+ -d, --debug Forces forever to log debug output
+ -v, --verbose Turns on the verbose messages from Forever
+ -s, --silent Run the child script silencing stdout and stderr
+ -w, --watch Watch for file changes
+ --watchDirectory Top-level directory to watch from
+ -h, --help You're staring at it
+
+ [Long Running Process]
+ The forever process will continue to run outputting log messages to the console.
+ ex. forever -o out.log -e err.log my-script.js
+
+ [Daemon]
+ The forever process will run as a daemon which will make the target process start
+ in the background. This is extremely useful for remote starting simple node.js scripts
+ without using nohup. It is recommended to run start with -o -l, & -e.
+ ex. forever start -l forever.log -o out.log -e err.log my-daemon.js
+ forever stop my-daemon.js
+```
+
+There are several examples designed to test the fault tolerance of forever. Here's a simple usage example:
+
+``` bash
+ $ forever -m 5 examples/error-on-timer.js
+```
+
+### Using an instance of Forever from node.js
+You can also use forever from inside your own node.js code.
+
+``` js
+ var forever = require('forever');
+
+ var child = new (forever.Monitor)('your-filename.js', {
+ max: 3,
+ silent: true,
+ options: []
+ });
+
+ child.on('exit', this.callback);
+ child.start();
+```
+
+**Remark:** As of `forever@0.6.0` processes will not automatically be available in `forever.list()`. In order to get your processes into `forever.list()` or `forever list` you must instantiate the `forever` socket server:
+
+``` js
+ forever.startServer(child);
+```
+
+### Spawning a non-node process
+You can spawn non-node processes too. Either set the `command` key in the
+`options` hash or pass in an `Array` in place of the `file` argument like this:
+
+``` js
+ var forever = require('forever');
+ var child = forever.start([ 'perl', '-le', 'print "moo"' ], {
+ max : 1,
+ silent : true
+ });
+```
+
+### Options available when using Forever in node.js
+There are several options that you should be aware of when using forever. Most of this configuration is optional.
+
+``` js
+ {
+ //
+ // Basic configuration options
+ //
+ 'silent': false, // Silences the output from stdout and stderr in the parent process
+ 'uid': 'your-UID' // Custom uid for this forever process. (default: autogen)
+ 'pidFile': 'path/to/a.pid', // Path to put pid information for the process(es) started
+ 'max': 10, // Sets the maximum number of times a given script should run
+ 'killTree': true // Kills the entire child process tree on `exit`
+
+ //
+ // These options control how quickly forever restarts a child process
+ // as well as when to kill a "spinning" process
+ //
+ 'minUptime': 2000, // Minimum time a child process has to be up. Forever will 'exit' otherwise.
+ 'spinSleepTime': 1000, // Interval between restarts if a child is spinning (i.e. alive < minUptime).
+
+ //
+ // Command to spawn as well as options and other vars
+ // (env, cwd, etc) to pass along
+ //
+ 'command': 'perl', // Binary to run (default: 'node')
+ 'options': ['foo','bar'], // Additional arguments to pass to the script,
+ 'sourceDir': 'script/path' // Directory that the source script is in
+
+ //
+ // Options for restarting on watched files.
+ //
+ 'watch': false // Value indicating if we should watch files.
+ 'watchIgnoreDotFiles': null // Dot files we should read to ignore ('.foreverignore', etc).
+ 'watchIgnorePatterns': null // Ignore patterns to use when watching files.
+ 'watchDirectory': null // Top-level directory to watch from.
+
+ //
+ // All or nothing options passed along to `child_process.spawn`.
+ //
+ 'spawnWith': {
+ env: process.env, // Information passed along to the child process
+ customFds: [-1, -1, -1], // that forever spawns.
+ setsid: false
+ },
+
+ //
+ // More specific options to pass along to `child_process.spawn` which
+ // will override anything passed to the `spawnWith` option
+ //
+ 'env': { 'ADDITIONAL': 'CHILD ENV VARS' }
+ 'cwd': '/path/to/child/working/directory'
+
+ //
+ // Log files and associated logging options for this instance
+ //
+ 'logFile': 'path/to/file', // Path to log output from forever process (when daemonized)
+ 'outFile': 'path/to/file', // Path to log output from child stdout
+ 'errFile': 'path/to/file' // Path to log output from child stderr
+ }
+```
+
+### Events available when using an instance of Forever in node.js
+Each forever object is an instance of the node.js core EventEmitter. There are several core events that you can listen for:
+
+* **error** _[err]:_ Raised when an error occurs
+* **start** _[process, data]:_ Raised when the target script is first started.
+* **stop** _[process]:_ Raised when the target script is stopped by the user
+* **restart** _[forever]:_ Raised each time the target script is restarted
+* **exit** _[forever]:_ Raised when the target script actually exits (permenantly).
+* **stdout** _[data]:_ Raised when data is received from the child process' stdout
+* **stderr** _[data]:_ Raised when data is received from the child process' stderr
+
+## Using forever module from node.js
+In addition to using a Forever object, the forever module also exposes some useful methods. Each method returns an instance of an EventEmitter which emits when complete. See the [forever cli commands][1] for sample usage.
+
+### forever.load (config)
+_Synchronously_ sets the specified configuration (config) for the forever module. There are two important options:
+
+* root: Directory to put all default forever log files
+* pidPath: Directory to put all forever *.pid files
+
+### forever.start (file, options)
+Starts a script with forever.
+
+### forever.startDaemon (file, options)
+Starts a script with forever as a daemon. WARNING: Will daemonize the current process.
+
+### forever.stop (index)
+Stops the forever daemon script at the specified index. These indices are the same as those returned by forever.list(). This method returns an EventEmitter that raises the 'stop' event when complete.
+
+### forever.stopAll (format)
+Stops all forever scripts currently running. This method returns an EventEmitter that raises the 'stopAll' event when complete.
+
+### forever.list (format, callback)
+Returns a list of metadata objects about each process that is being run using forever. This method is synchronous and will return the list of metadata as such. Only processes which have invoked `forever.startServer()` will be available from `forever.list()`
+
+### forever.tail (target, [length,] callback)
+Responds with the logs from the target script(s) from `tail`. If `length` is provided it is used as the `-n` parameter to `tail`.
+
+### forever.cleanUp ()
+Cleans up any extraneous forever *.pid files that are on the target system. This method returns an EventEmitter that raises the 'cleanUp' event when complete.
+
+### forever.cleanLogsSync (processes)
+Removes all log files from the root forever directory that do not belong to current running forever processes.
+
+## Run Tests
+
+``` bash
+ $ npm test
+```
+
+#### Author: [Charlie Robbins][0]
+#### Contributors: [Fedor Indutny](http://github.com/donnerjack13589), [James Halliday](http://substack.net/)
+
+[0]: http://nodejitsu.com
+[1]: https://github.com/nodejitsu/forever/blob/master/lib/forever/cli.js
20 node_modules/forever/bin/forever
@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+var fs = require('fs');
+
+if (process.send) {
+ //
+ // Supress `stdout` and `stderr` when `forever` is being run as a fork.
+ // We use `child_process.fork` to daemonize `forever` processes, so
+ // outputting anything isn't a desired situation.
+ //
+ var nullStream = fs.createWriteStream('/dev/null');
+ var returner = function () {
+ return nullStream;
+ };
+ process.__defineGetter__('stdout', returner);
+ process.__defineGetter__('stderr', returner);
+}
+
+var forever = require('../lib/forever');
+forever.cli.start();
4 node_modules/forever/bin/foreverd
@@ -0,0 +1,4 @@
+#!/usr/bin/env node
+
+require('../lib/forever/service/cli').startCLI();
+
194 node_modules/forever/docs/docco.css
@@ -0,0 +1,194 @@
+/*--------------------- Layout and Typography ----------------------------*/
+body {
+ font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
+ font-size: 15px;
+ line-height: 22px;
+ color: #252519;
+ margin: 0; padding: 0;
+}
+a {
+ color: #261a3b;
+}
+ a:visited {
+ color: #261a3b;
+ }
+p {
+ margin: 0 0 15px 0;
+}
+h4, h5, h6 {
+ color: #333;
+ margin: 6px 0 6px 0;
+ font-size: 13px;
+}
+ h2, h3 {
+ margin-bottom: 0;
+ color: #000;
+ }
+ h1 {
+ margin-top: 40px;
+ margin-bottom: 15px;
+ color: #000;
+ }
+#container {
+ position: relative;
+}
+#background {
+ position: fixed;
+ top: 0; left: 525px; right: 0; bottom: 0;
+ background: #f5f5ff;
+ border-left: 1px solid #e5e5ee;
+ z-index: -1;
+}
+#jump_to, #jump_page {
+ background: white;
+ -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
+ -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
+ font: 10px Arial;
+ text-transform: uppercase;
+ cursor: pointer;
+ text-align: right;
+}
+#jump_to, #jump_wrapper {
+ position: fixed;
+ right: 0; top: 0;
+ padding: 5px 10px;
+}
+ #jump_wrapper {
+ padding: 0;
+ display: none;
+ }
+ #jump_to:hover #jump_wrapper {
+ display: block;
+ }
+ #jump_page {
+ padding: 5px 0 3px;
+ margin: 0 0 25px 25px;
+ }
+ #jump_page .source {
+ display: block;
+ padding: 5px 10px;
+ text-decoration: none;
+ border-top: 1px solid #eee;
+ }
+ #jump_page .source:hover {
+ background: #f5f5ff;
+ }
+ #jump_page .source:first-child {
+ }
+table td {
+ border: 0;
+ outline: 0;
+}
+ td.docs, th.docs {
+ max-width: 450px;
+ min-width: 450px;
+ min-height: 5px;
+ padding: 10px 25px 1px 50px;
+ overflow-x: hidden;
+ vertical-align: top;
+ text-align: left;
+ }
+ .docs pre {
+ margin: 15px 0 15px;
+ padding-left: 15px;
+ }
+ .docs p tt, .docs p code {
+ background: #f8f8ff;
+ border: 1px solid #dedede;
+ font-size: 12px;
+ padding: 0 0.2em;
+ }
+ .pilwrap {
+ position: relative;
+ }
+ .pilcrow {
+ font: 12px Arial;
+ text-decoration: none;
+ color: #454545;
+ position: absolute;
+ top: 3px; left: -20px;
+ padding: 1px 2px;
+ opacity: 0;
+ -webkit-transition: opacity 0.2s linear;
+ }
+ td.docs:hover .pilcrow {
+ opacity: 1;
+ }
+ td.code, th.code {
+ padding: 14px 15px 16px 25px;
+ width: 100%;
+ vertical-align: top;
+ background: #f5f5ff;
+ border-left: 1px solid #e5e5ee;
+ }
+ pre, tt, code {
+ font-size: 12px; line-height: 18px;
+ font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
+ margin: 0; padding: 0;
+ }
+
+
+/*---------------------- Syntax Highlighting -----------------------------*/
+td.linenos { background-color: #f0f0f0; padding-right: 10px; }
+span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
+body .hll { background-color: #ffffcc }
+body .c { color: #408080; font-style: italic } /* Comment */
+body .err { border: 1px solid #FF0000 } /* Error */
+body .k { color: #954121 } /* Keyword */
+body .o { color: #666666 } /* Operator */
+body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
+body .cp { color: #BC7A00 } /* Comment.Preproc */
+body .c1 { color: #408080; font-style: italic } /* Comment.Single */
+body .cs { color: #408080; font-style: italic } /* Comment.Special */
+body .gd { color: #A00000 } /* Generic.Deleted */
+body .ge { font-style: italic } /* Generic.Emph */
+body .gr { color: #FF0000 } /* Generic.Error */
+body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+body .gi { color: #00A000 } /* Generic.Inserted */
+body .go { color: #808080 } /* Generic.Output */
+body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+body .gs { font-weight: bold } /* Generic.Strong */
+body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+body .gt { color: #0040D0 } /* Generic.Traceback */
+body .kc { color: #954121 } /* Keyword.Constant */
+body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
+body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
+body .kp { color: #954121 } /* Keyword.Pseudo */
+body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
+body .kt { color: #B00040 } /* Keyword.Type */
+body .m { color: #666666 } /* Literal.Number */
+body .s { color: #219161 } /* Literal.String */
+body .na { color: #7D9029 } /* Name.Attribute */
+body .nb { color: #954121 } /* Name.Builtin */
+body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
+body .no { color: #880000 } /* Name.Constant */
+body .nd { color: #AA22FF } /* Name.Decorator */
+body .ni { color: #999999; font-weight: bold } /* Name.Entity */
+body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+body .nf { color: #0000FF } /* Name.Function */
+body .nl { color: #A0A000 } /* Name.Label */
+body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+body .nt { color: #954121; font-weight: bold } /* Name.Tag */
+body .nv { color: #19469D } /* Name.Variable */
+body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+body .w { color: #bbbbbb } /* Text.Whitespace */
+body .mf { color: #666666 } /* Literal.Number.Float */
+body .mh { color: #666666 } /* Literal.Number.Hex */
+body .mi { color: #666666 } /* Literal.Number.Integer */
+body .mo { color: #666666 } /* Literal.Number.Oct */
+body .sb { color: #219161 } /* Literal.String.Backtick */
+body .sc { color: #219161 } /* Literal.String.Char */
+body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
+body .s2 { color: #219161 } /* Literal.String.Double */
+body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+body .sh { color: #219161 } /* Literal.String.Heredoc */
+body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+body .sx { color: #954121 } /* Literal.String.Other */
+body .sr { color: #BB6688 } /* Literal.String.Regex */
+body .s1 { color: #219161 } /* Literal.String.Single */
+body .ss { color: #19469D } /* Literal.String.Symbol */
+body .bp { color: #954121 } /* Name.Builtin.Pseudo */
+body .vc { color: #19469D } /* Name.Variable.Class */
+body .vg { color: #19469D } /* Name.Variable.Global */
+body .vi { color: #19469D } /* Name.Variable.Instance */
+body .il { color: #666666 } /* Literal.Number.Integer.Long */
608 node_modules/forever/docs/forever.html
608 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
289 node_modules/forever/docs/forever/cli.html
@@ -0,0 +1,289 @@
+<!DOCTYPE html> <html> <head> <title>cli.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//forever/cli.html"> forever/cli.html </a> <a class="source" href="..//forever/monitor.html"> forever/monitor.html </a> <a class="source" href="..//forever.html"> forever.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> cli.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * cli.js: Handlers for the forever CLI commands.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010 Charlie Robbins</span>
+<span class="cm"> * MIT LICENCE</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">sys</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;sys&#39;</span><span class="p">),</span>
+ <span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;path&#39;</span><span class="p">),</span>
+ <span class="nx">cliff</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;cliff&#39;</span><span class="p">),</span>
+ <span class="nx">forever</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../forever&#39;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">cli</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">;</span>
+
+<span class="kd">var</span> <span class="nx">reserved</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;pidPath&#39;</span><span class="p">];</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function exec (action, file, options)</h3>
+
+<h4>@action {string} CLI action to execute</h4>
+
+<h4>@file {string} Location of the target forever script or process.</h4>
+
+<h4>@options {Object} Options to pass to forever for the <code>action</code>.</h4>
+
+<p>Executes the <code>action</code> in forever with the specified <code>file</code> and <code>options</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">exec</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">action</span><span class="p">,</span> <span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">display</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">action</span><span class="p">)</span> <span class="o">?</span> <span class="nx">action</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="o">:</span> <span class="nx">action</span><span class="p">;</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">action</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Running action: &#39;</span> <span class="o">+</span> <span class="nx">display</span><span class="p">.</span><span class="nx">yellow</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">action</span> <span class="o">===</span> <span class="s1">&#39;cleanlogs&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">silly</span><span class="p">(</span><span class="s1">&#39;Tidying &#39;</span> <span class="o">+</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">));</span>
+ <span class="kd">var</span> <span class="nx">tidy</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">cleanUp</span><span class="p">(</span><span class="nx">action</span> <span class="o">===</span> <span class="s1">&#39;cleanlogs&#39;</span><span class="p">);</span>
+ <span class="nx">tidy</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;cleanUp&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">silly</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; tidied.&#39;</span><span class="p">);</span>
+ <span class="p">});</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">file</span> <span class="o">&amp;&amp;</span> <span class="nx">action</span> <span class="o">===</span> <span class="s1">&#39;start&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever processing file: &#39;</span> <span class="o">+</span> <span class="nx">file</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">command</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever using command: &#39;</span> <span class="o">+</span> <span class="nx">options</span><span class="p">.</span><span class="nx">command</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">options</span> <span class="o">&amp;&amp;</span> <span class="nx">action</span> <span class="o">!==</span> <span class="s1">&#39;set&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">silly</span><span class="p">(</span><span class="s1">&#39;Forever using options&#39;</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
+ <span class="p">}</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>If there is no action then start in the current
+process with the specified <code>file</code> and <code>options</code>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">action</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">cli</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="k">return</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">action</span><span class="p">)</span>
+ <span class="o">?</span> <span class="nx">cli</span><span class="p">[</span><span class="nx">action</span><span class="p">[</span><span class="mi">0</span><span class="p">]](</span><span class="nx">action</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="nx">options</span><span class="p">)</span>
+ <span class="o">:</span> <span class="nx">cli</span><span class="p">[</span><span class="nx">action</span><span class="p">](</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>function start (file, options, daemon)</h3>
+
+<h4>@file {string} Location of the script to spawn with forever</h4>
+
+<h4>@options {Object} Options to spawn the script <code>file</code> with.</h4>
+
+<h4>@daemon {boolean} Value indicating if we should spawn as a daemon</h4>
+
+<p>Starts a forever process for the script located at <code>file</code> with the
+specified <code>options</code>. If <code>daemon</code> is true, then the script will be
+started as a daemon process.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">start</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="nx">daemon</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">tryStart</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">monitor</span> <span class="o">=</span> <span class="nx">daemon</span>
+ <span class="o">?</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">startDaemon</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span>
+ <span class="o">:</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">start</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
+
+ <span class="nx">monitor</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">startServer</span><span class="p">(</span><span class="nx">monitor</span><span class="p">);</span>
+ <span class="p">});</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h3>function stop (file)</h3>
+
+<h4>@file {string} Target forever process to stop</h4>
+
+<p>Stops the forever process specified by <code>file</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">stop</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">runner</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">stop</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+
+ <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;stop&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">process</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever stopped process:&#39;</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">process</span><span class="p">);</span>
+ <span class="p">});</span>
+
+ <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Forever cannot find process with index: &#39;</span> <span class="o">+</span> <span class="nx">file</span><span class="p">)</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h3>function stopall ()</h3>
+
+<p>Stops all currently running forever processes.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">stopall</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">runner</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">stopAll</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
+ <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;stopAll&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever stopped processes:&#39;</span><span class="p">);</span>
+ <span class="nx">processes</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;No forever processes running&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>function restart (file)</h3>
+
+<h4>@file {string} Target process to restart</h4>
+
+<p>Restarts the forever process specified by <code>file</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">restart</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">file</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">runner</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">restart</span><span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
+ <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;restart&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever restarted process(es):&#39;</span><span class="p">);</span>
+ <span class="nx">processes</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
+ <span class="p">});</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;No forever processes running&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="p">});</span>
+
+ <span class="nx">runner</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Error restarting process: &#39;</span> <span class="o">+</span> <span class="nx">file</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <h3>function list ()</h3>
+
+<p>Lists all currently running forever processes.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">list</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">list</span><span class="p">(</span><span class="kc">true</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">processes</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever processes running&#39;</span><span class="p">);</span>
+ <span class="nx">processes</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
+ <span class="p">})</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;No forever processes running&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <h3>function config ()</h3>
+
+<p>Lists all of the configuration in <code>~/.forever/config.json</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">config</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">keys</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">store</span><span class="p">),</span>
+ <span class="nx">conf</span> <span class="o">=</span> <span class="nx">cliff</span><span class="p">.</span><span class="nx">inspect</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">store</span><span class="p">);</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">keys</span><span class="p">.</span><span class="nx">length</span> <span class="o">&lt;=</span> <span class="mi">2</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">conf</span> <span class="o">=</span> <span class="nx">conf</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\{\s/</span><span class="p">,</span> <span class="s1">&#39;{ \n&#39;</span><span class="p">)</span>
+ <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\}/</span><span class="p">,</span> <span class="s1">&#39;\n}&#39;</span><span class="p">)</span>
+ <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="s1">&#39;\033[90m&#39;</span><span class="p">,</span> <span class="s1">&#39; \033[90m&#39;</span><span class="p">)</span>
+ <span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/, /ig</span><span class="p">,</span> <span class="s1">&#39;,\n &#39;</span><span class="p">)</span>
+ <span class="p">}</span>
+ <span class="k">else</span> <span class="p">{</span>
+ <span class="nx">conf</span> <span class="o">=</span> <span class="nx">conf</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/\n\s{4}/ig</span><span class="p">,</span> <span class="s1">&#39;\n &#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">conf</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s1">&#39;\n&#39;</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">line</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="nx">line</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h3>function set (key, value)</h3>
+
+<h4>@key {string} Key to set in forever config</h4>
+
+<h4>@value {string} Value to set for <code>key</code></h4>
+
+<p>Sets the specified <code>key</code> / <code>value</code> pair in the
+forever user config.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">set</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">key</span> <span class="o">||</span> <span class="o">!</span><span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Both &lt;key&gt; and &lt;value&gt; are required.&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">updateConfig</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Setting forever config: &#39;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <h3>function clear (key)</h3>
+
+<h4>@key {string} Key to remove from <code>~/.forever/config.json</code></h4>
+
+<p>Removes the specified <code>key</code> from the forever user config.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">clear</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">reserved</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="o">!==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s1">&#39;Cannot clear reserved config: &#39;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s1">&#39;Use `forever set &#39;</span> <span class="o">+</span> <span class="nx">key</span> <span class="o">+</span> <span class="s1">&#39;` instead&#39;</span><span class="p">);</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="nx">updateConfig</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Clearing forever config: &#39;</span> <span class="o">+</span> <span class="nx">key</span><span class="p">.</span><span class="nx">grey</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">clear</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">};</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <h3>function columns (action, value)</h3>
+
+<h4>@action {string} The subaction to execute</h4>
+
+<h4>@value {Array} The value to use in the specified <code>action</code>.</h4>
+
+<p>Executes the specified subaction: <code>add</code>, <code>rm</code>, and <code>set</code> which
+add, remove, or completely overrides the columns used by <code>forever list</code>
+and <code>forever.list()</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">cli</span><span class="p">.</span><span class="nx">columns</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">action</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!~</span><span class="p">[</span><span class="s1">&#39;add&#39;</span><span class="p">,</span> <span class="s1">&#39;rm&#39;</span><span class="p">,</span> <span class="s1">&#39;set&#39;</span><span class="p">].</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">action</span><span class="p">))</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Invalid action: &#39;</span> <span class="o">+</span> <span class="p">(</span><span class="s1">&#39;columns &#39;</span> <span class="o">+</span> <span class="nx">action</span><span class="p">).</span><span class="nx">yellow</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Use: &#39;</span> <span class="o">+</span> <span class="s1">&#39;columns &lt;add|rm|set&gt;&#39;</span><span class="p">.</span><span class="nx">yellow</span><span class="p">);</span>
+ <span class="k">return</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="kd">var</span> <span class="nx">columns</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;columns&#39;</span><span class="p">),</span>
+ <span class="nx">actions</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">add</span><span class="o">:</span> <span class="nx">addColumn</span><span class="p">,</span> <span class="nx">rm</span><span class="o">:</span> <span class="nx">rmColumn</span><span class="p">,</span> <span class="nx">set</span><span class="o">:</span> <span class="nx">setColumns</span> <span class="p">},</span>
+ <span class="nx">allColumns</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">columns</span><span class="p">);</span>
+
+ <span class="kd">function</span> <span class="nx">addColumn</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">~</span><span class="nx">columns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">))</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span> <span class="o">+</span> <span class="s1">&#39; already exists in forever&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Adding column: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="nx">columns</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="kd">function</span> <span class="nx">rmColumn</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!~</span><span class="nx">columns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">))</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span> <span class="o">+</span> <span class="s1">&#39; doesn\&#39;t exist in forever&#39;</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Removing column: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="nx">columns</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">columns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">),</span> <span class="mi">1</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="kd">function</span> <span class="nx">setColumns</span> <span class="p">()</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Setting columns: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">).</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="nx">columns</span> <span class="o">=</span> <span class="nx">value</span><span class="p">;</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="nx">action</span> <span class="o">!==</span> <span class="s1">&#39;set&#39;</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span>
+ <span class="p">}</span>
+
+ <span class="k">if</span> <span class="p">(</span><span class="o">!~</span><span class="nx">allColumns</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">value</span><span class="p">))</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Unknown column: &#39;</span> <span class="o">+</span> <span class="nx">value</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">actions</span><span class="p">[</span><span class="nx">action</span><span class="p">]();</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">&#39;columns&#39;</span><span class="p">,</span> <span class="nx">columns</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">saveSync</span><span class="p">();</span>
+<span class="p">}</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <h3>@private function (file, options, callback)</h3>
+
+<h4>@file {string} Target script to start</h4>
+
+<h4>@options {Object} Options to start the script with</h4>
+
+<h4>@callback {function} Continuation to respond to when complete.</h4>
+
+<p>Helper function that sets up the pathing for the specified <code>file</code>
+then stats the appropriate files and responds.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">function</span> <span class="nx">tryStart</span> <span class="p">(</span><span class="nx">file</span><span class="p">,</span> <span class="nx">options</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">fullLog</span><span class="p">,</span> <span class="nx">fullScript</span><span class="p">;</span>
+
+ <span class="nx">fullLog</span> <span class="o">=</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">logFilePath</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">logFile</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">uid</span><span class="p">);</span>
+ <span class="nx">fullScript</span> <span class="o">=</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">options</span><span class="p">.</span><span class="nx">sourceDir</span><span class="p">,</span> <span class="nx">file</span><span class="p">);</span>
+
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">stat</span><span class="p">(</span><span class="nx">fullLog</span><span class="p">,</span> <span class="nx">fullScript</span><span class="p">,</span> <span class="nx">options</span><span class="p">.</span><span class="nx">appendLog</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Cannot start forever&#39;</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
+ <span class="nx">process</span><span class="p">.</span><span class="nx">exit</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">callback</span><span class="p">();</span>
+ <span class="p">});</span>
+<span class="p">}</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <h3>@private function updateConfig (updater)</h3>
+
+<h4>@updater {function} Function which updates the forever config</h4>
+
+<p>Helper which runs the specified <code>updater</code> and then saves the forever
+config to <code>forever.config.get('root')</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">function</span> <span class="nx">updateConfig</span> <span class="p">(</span><span class="nx">updater</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">updater</span><span class="p">();</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">save</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">err</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s1">&#39;Error saving config: &#39;</span> <span class="o">+</span> <span class="nx">err</span><span class="p">.</span><span class="nx">message</span><span class="p">);</span>
+ <span class="p">}</span>
+
+ <span class="nx">cli</span><span class="p">.</span><span class="nx">config</span><span class="p">();</span>
+ <span class="kd">var</span> <span class="nx">configFile</span> <span class="o">=</span> <span class="nx">path</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="nx">forever</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">),</span> <span class="s1">&#39;config.json&#39;</span><span class="p">);</span>
+ <span class="nx">forever</span><span class="p">.</span><span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">&#39;Forever config saved: &#39;</span> <span class="o">+</span> <span class="nx">configFile</span><span class="p">.</span><span class="nx">yellow</span><span class="p">);</span>
+ <span class="p">});</span>
+<span class="p">}</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
274 node_modules/forever/docs/forever/monitor.html
@@ -0,0 +1,274 @@
+<!DOCTYPE html> <html> <head> <title>monitor.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="..//forever/cli.html"> forever/cli.html </a> <a class="source" href="..//forever/monitor.html"> forever/monitor.html </a> <a class="source" href="..//forever.html"> forever.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> monitor.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
+<span class="cm"> * monitor.js: Core functionality for the Monitor object.</span>
+<span class="cm"> *</span>
+<span class="cm"> * (C) 2010 Charlie Robbins</span>
+<span class="cm"> * MIT LICENCE</span>
+<span class="cm"> *</span>
+<span class="cm"> */</span>
+
+<span class="kd">var</span> <span class="nx">sys</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;sys&#39;</span><span class="p">),</span>
+ <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">),</span>
+ <span class="nx">path</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;path&#39;</span><span class="p">),</span>
+ <span class="nx">events</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;events&#39;</span><span class="p">),</span>
+ <span class="nx">spawn</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;child_process&#39;</span><span class="p">).</span><span class="nx">spawn</span><span class="p">,</span>
+ <span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;winston&#39;</span><span class="p">),</span>
+ <span class="nx">forever</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../forever&#39;</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>function Monitor (script, options)</h3>
+
+<h4>@script {string} Location of the target script to run.</h4>
+
+<h4>@options {Object} Configuration for this instance.</h4>
+
+<p>Creates a new instance of forever with specified params.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Monitor</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Monitor</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">script</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
+ <span class="nx">events</span><span class="p">.</span><span class="nx">EventEmitter</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Setup basic configuration options</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">options</span> <span class="o">=</span> <span class="nx">options</span> <span class="o">||</span> <span class="p">{};</span>
+ <span class