Giter VIP home page Giter VIP logo

forever's Introduction

forever

Join the chat at https://gitter.im/foreverjs/forever

Version npmnpm DownloadsBuild StatusDependenciesInline docs

NPM

A simple CLI tool for ensuring that a given script runs continuously (i.e. forever). Note that this project currently fully depends on the community for implementing fixes and new features. For new installations we encourage you to use pm2 or nodemon

Installation

  $ [sudo] npm install forever -g

Note: If you are using forever programmatically you should install forever-monitor.

  $ cd /path/to/your/project
  $ [sudo] npm install forever-monitor

Usage

There are two ways to use forever: through the command line or by using forever in your code. Note: If you are using forever programatically you should install forever-monitor.

Command Line Usage

You can use forever to run scripts continuously (whether it is written in node.js or not).

Example

forever start app.js

Options

  $ forever --help
  usage: forever [action] [options] 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 by Id|Uid|Pid|Index|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`. Supported columns: 'uid', 'command', 'script', 'forever', 'pid', 'id', 'logfile', 'uptime'
    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`
    columns reset       Resets all columns to defaults 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
    -f, --fifo       Stream logs to stdout
    -n, --number     Number of log lines to print
    --pidFile        The pid file
    --uid            DEPRECATED. Process uid, useful as a namespace for processes (must wrap in a string)
                     e.g. forever start --uid "production" app.js
                         forever stop production
    --id             DEPRECATED. Process id, similar to uid, useful as a namespace for processes (must wrap in a string)
                     e.g. forever start --id "test" app.js
                         forever stop test
    --sourceDir      The source directory for which SCRIPT is relative to
    --workingDir     The working directory in which SCRIPT will execute
    --minUptime      Minimum uptime (millis) for a script to not be considered "spinning"
    --spinSleepTime  Time to wait (millis) between launches of a spinning script.
    --colors         --no-colors will disable output coloring
    --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
    --watchIgnore    To ignore pattern when watch is enabled (multiple option is allowed)
    -t, --killTree   Kills the entire child process tree on `stop`
    --killSignal     Support exit signal customization (default is SIGKILL),
                     used for restarting script gracefully e.g. --killSignal=SIGTERM
                     Any console output generated after calling `forever stop/stopall` will not appear in the logs
    -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:

  $ forever -m 5 examples/error-on-timer.js

JSON Configuration Files

In addition to passing forever the path to a script (along with accompanying options, described above), you may also pass forever the path to a JSON file containing these options. For example, consider an application with the following file structure:

.
├── forever
│   └── development.json
└── index.js

// forever/development.json
{
	// Comments are supported
    "uid": "app",
    "append": true,
    "watch": true,
    "script": "index.js",
    "sourceDir": "/home/myuser/app",
    "logFile": "/home/myuser/logs/forever.log",
    "outFile": "/home/myuser/logs/out.log",
    "errFile": "/home/myuser/logs/error.log"
}

This application could be started with forever, as shown below:

$ forever start ./forever/development.json

Absolute paths to such configuration files are also supported:

$ forever start /home/myuser/app/forever/development.json

Note: Forever parses JSON configuration files using shush, allowing the use of in-line comments within such files.

Multi-App Configuration Files

JSON configuration files can also be used to define the startup options for multiple applications, as shown below.

[
  {
    // App1
    "uid": "app1",
    "append": true,
    "watch": true,
    "script": "index.js",
    "sourceDir": "/home/myuser/app1"
  },
  {
    // App2
    "uid": "app2",
    "append": true,
    "watch": true,
    "script": "index.js",
    "sourceDir": "/home/myuser/app2",
    "args": ["--port", "8081"]
  }
]

Using In Your Code

The forever module exposes some useful methods to use in your code. Each method returns an instance of an EventEmitter which emits when complete. See the forever cli commands for sample usage.

Remark: As of [email protected] 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:

  forever.startServer(child);

This method takes multiple forever.Monitor instances which are defined in the forever-monitor dependency.

forever.load (config)

Synchronously sets the specified configuration (config) for the forever module. There are two important options:

Option Description   Default
root Directory to put all default forever log files forever.root
pidPath Directory to put all forever *.pid files [root]/pids
sockPath Directory for sockets for IPC between workers [root]/sock
loglength Number of logs to return in forever tail 100
columns Array of columns to display when format is true forever.config.get('columns')
debug Boolean value indicating to run in debug mode false
stream Boolean value indicating if logs will be streamed false

forever.start (file, options)

Starts a script with forever. The options object is what is expected by the Monitor of forever-monitor.

forever.startDaemon (file, options)

Starts a script with forever as a daemon. WARNING: Will daemonize the current process. The options object is what is expected by the Monitor of forever-monitor.

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.

The format parameter is a boolean value indicating whether the returned values should be formatted according to the configured columns which can set with forever columns or programmatically forever.config.set('columns').

forever.list (format, callback)

Returns a list of metadata objects about each process that is being run using forever. This method will return the list of metadata as such. Only processes which have invoked forever.startServer() will be available from forever.list()

The format parameter is a boolean value indicating whether the returned values should be formatted according to the configured columns which can set with forever columns or programmatically forever.config.set('columns').

forever.tail (target, options, callback)

Responds with the logs from the target script(s) from tail. There are two options:

  • length (numeric): is is used as the -n parameter to tail.
  • stream (boolean): is is used as the -f 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. Processes are the value returned from Monitor.data in forever-monitor.

forever.startServer (monitor0, monitor1, ..., monitorN)

Starts the forever HTTP server for communication with the forever CLI. NOTE: This will change your process.title. This method takes multiple forever.Monitor instances which are defined in the forever-monitor dependency.

Logging and output file locations

By default forever places all of the files it needs into /$HOME/.forever. If you would like to change that location just set the FOREVER_ROOT environment variable when you are running forever:

FOREVER_ROOT=/etc/forever forever start index.js

Make sure that the user running the process has the appropriate privileges to read & write to this directory.

Run Tests

  $ npm test

License: MIT

Maintainer: Igor Savin

forever's People

Contributors

3rd-eden avatar andrewmartin avatar andrewradev avatar anthonyakentiev avatar armetiz avatar avianflu avatar bmeck avatar coderarity avatar fb55 avatar fedot avatar gitter-badger avatar indexzero avatar indutny avatar jcrugzz avatar jfhbrook avatar jlank avatar julianduque avatar kerphi avatar kibertoad avatar kontakter avatar kpdecker avatar marak avatar mmalecki avatar ryana avatar sapics avatar seanhussey avatar shenanigans avatar thenengah avatar tjatse avatar tkambler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forever's Issues

Stop and Stop All glitchs

Hello,

I usually use Forever to launch one node script as a backend web service, and I notice something weird with the newer version.
After i call forever stop 0, It seems to tell me it stopped my service, yet if I now type forever list, it is still there.However, If i try to stop 0 again, it isn't available to stop. and Stop all ends with a error. Here's the console below.

Thanks again for this great tool, and hope I can help you debug this.

ubuntu@ip-:~/code$ forever stop 0
info: Running action: stop
info: Forever stopped process:
  [0] overlay.js [4063, 4062] /home/ubuntu/.forever/G-nZ.log 0:0:4:53.542
ubuntu@ip-0:~/code$ forever list
info: Running action: list
info: Forever processes running
  [0] overlay.js [4063, 4062] /home/ubuntu/.forever/G-nZ.log 0:0:4:55.576
ubuntu@ip-:~/code$ forever stop 0
info: Running action: stop
error: Forever cannot find process with index: 0
ubuntu@ip-:~/code$ forever stop all
info: Running action: stop
info: Forever processing file: all

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Cannot call method 'filter' of null
    at Object.findByScript (/home/ubuntu/.nvm/v0.4.7/lib/node/.npm/forever/0.5.1/package/lib/forever.js:286:20)
    at Object.stop (/home/ubuntu/.nvm/v0.4.7/lib/node/.npm/forever/0.5.1/package/lib/forever.js:188:46)
    at Object.stop (/home/ubuntu/.nvm/v0.4.7/lib/node/.npm/forever/0.5.1/package/lib/forever/cli.js:95:24)
    at EventEmitter. (/home/ubuntu/.nvm/v0.4.7/lib/node/.npm/forever/0.5.1/package/lib/forever/cli.js:68:15)
    at EventEmitter.emit (events.js:61:17)
    at Array. (/home/ubuntu/.nvm/v0.4.7/lib/node/.npm/forever/0.5.1/package/lib/forever.js:396:15)
    at EventEmitter._tickCallback (node.js:126:26)
ubuntu@ip:~/code$ 

Crash using 'start'

When I try forever start test.js I get

fs:145
binding.open(path, stringToFlags(flags), mode, callback || noop);
^
TypeError: Bad argument
at Object.open (fs:145:11)
at Object.startDaemon (/usr/local/lib/node/.npm/forever/0.3.0/package/lib/forever.js:63:6)
at EventEmitter. (/usr/local/lib/node/.npm/forever/0.3.0/package/bin/forever:110:19)
at EventEmitter.emit (events:26:26)
at Array.0 (/usr/local/lib/node/.npm/forever/0.3.0/package/lib/forever.js:211:15)
at EventEmitter._tickCallback (node.js:53:20)
at node.js:764:9

where test.js is

var util = require('util'),
http = require('http');

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('hello, i know nodejitsu.')
res.end();
}).listen(8000);

/* server started */
util.puts('> hello world running on port 8000');

setTimeout(function () {
util.puts('Throwing error now.');
throw new Error('User generated fault.');
}, 5000);

I've tried it with other scripts too, all of which work with node normally. I'm up to date with npm.

Use of invalid action -> "Cannot read property 'yellow' of undefined"

For first time users who don't yet understand the cli syntax, you should anticipate errors. Currently if you use an invalid action, node throws up.

$ forever invalidAction myScript.js

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'yellow' of undefined
at Object.exec (/Users/drg/Code/node/lib/forever/lib/forever/cli.js:41:43)
at Object. (/Users/drg/Code/node/lib/forever/bin/forever:185:13)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array. (module.js:423:10)
at EventEmitter._tickCallback (node.js:126:26)

In cli.js you could add something like
cli.exec = function (action, file, options) {
if(!action) {
console.log("invalid action");
return false;
}

I would fix & do a pull request, but it's such a minor thing and figure you would have a better idea of how to integrate. :)

Cheers

Dreamhost Cron Job not restarting Forever

I have a cronjob set up on my Dreamhost vps account to check if node.js is running a specific script with Forever. The cron first loads the user environment by loading the /path/to/.bash_profile, then runs the php script which checks to see if forever is running the given node.js script: /path/to/check_node_app.php -s application_search.js. This php script runs the shell command forever list, checks for the script, then runs forever start if its not running. (the main reason for creating this script is because forever shut down once, maybe due to server reboot??)

software versions:
forever: 0.4.1
node: v0.4.4
npm: 0.3.15
OS: Linux ps39832 2.6.33.7-vs2.3.0.36.30.4 #23 SMP Tue Sep 28 05:47:35 PDT 2010 x86_64 GNU/Linux

It works perfectly if I run the php script from the command line of that user, but from the cron job, it spits out the error:

sh: forever: command not found

Then if I put the full path to forever in the script /usr/local/lib/node/.npm/forever/0.4.1/package/bin/forever I get this error:

sh: forever: command not found
/usr/bin/env: node: No such file or directory

I chose php for the script basically because I know php and not bash very well, though if this causes part of the issue I am fine to learn how to do it in bash. If there is nothing off the bat here that seems obvious is the issue, I'll update forever as Charlie suggested in an email from him.

Problem running forever 0.4.1 on node 0.4.3

Installed forever 0.4.1 using npm 1.0rc and on first run it gives such error:

   % forever -v

   node.js:134
           throw e; // process.nextTick error, or 'error' event on first tick
           ^
   Error: Cannot find module './lib/index'
       at Function._resolveFilename (module.js:320:11)
       at Function._load (module.js:266:25)
       at require (module.js:348:19)
       at Object.<anonymous> (/Users/jakub/node_modules/forever/node_modules/winston/node_modules/riak-js/index.js:1:80)
       at Module._compile (module.js:404:26)
       at Object..js (module.js:410:10)
       at Module.load (module.js:336:31)
       at Function._load (module.js:297:12)
       at require (module.js:348:19)
       at Object.<anonymous> (/Users/jakub/node_modules/forever/node_modules/winston/lib/winston/transports/riak.js:10:14)

Commenting out riak-js/index.js require solves the problem, but that's not the way it should be done.

Any ideas if that's something related to a bug in forever, new version of npm, broken winston, or riak-js?

forever list broken?

To preface this: I am a horrible user. I did not stop my running forever tasks before updating. Now when I run forever list it gives me the error below. To try and fix this, and make sure it is not all my fault, I npm uninstall forever, and then npm cache clean forevered and then reinstalled and I still have this problem. I am getting the same problem when I've started all my processes and when I have none running.

_It seems the error does not effect the actual running of forever, so this is a very good thing :)_

I won't be able to list my running scripts, but it's ok since it still works :)
-David

PS This is with forever 0.4.0 and node 0.4.0.

/usr/local/lib/node/.npm/forever/0.4.0/package/lib/forever.js:413
  return ['  [' + index + ']', proc.file.green]
                                        ^
TypeError: Cannot read property 'green' of undefined
    at formatProcess (/usr/local/lib/node/.npm/forever/0.4.0/package/lib/forever.js:413:41)
    at /usr/local/lib/node/.npm/forever/0.4.0/package/lib/forever.js:292:22
    at Array.forEach (native)
    at Object.list (/usr/local/lib/node/.npm/forever/0.4.0/package/lib/forever.js:289:11)
    at EventEmitter. (/usr/local/lib/node/.npm/forever/0.4.0/package/bin/forever:208:33)
    at EventEmitter.emit (events.js:39:17)
    at /usr/local/lib/node/.npm/forever/0.4.0/package/lib/forever.js:334:21
    at /usr/local/lib/node/.npm/forever/0.4.0/package/lib/forever.js:399:5
    at ChildProcess.exithandler (child_process.js:79:7)
    at ChildProcess.emit (events.js:45:17)

Forever not cleaning up ~/.forever/pids/

forever list command crashes because there are too many .fvr files (over 100). Maybe it is forever needs to clean up after it deletes or the list command should be fixed if there are too many files.

info: Running action: list
pipe(): Too many open files

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Error spawning
    at ChildProcess.spawn (child_process.js:243:28)
    at child_process.js:31:15
    at child_process.js:77:15
    at child_process.js:38:27
    at checkProcess (/usr/local/lib/node_modules/forever/lib/forever.js:482:3)
    at /usr/local/lib/node_modules/forever/lib/forever.js:372:7
    at Array.forEach (native)
    at Object.cleanUp (/usr/local/lib/node_modules/forever/lib/forever.js:371:15)
    at Object.exec (/usr/local/lib/node_modules/forever/lib/forever/cli.js:44:22)
    at Object.<anonymous> (/usr/local/lib/node_modules/forever/bin/forever:185:13)

Unable to install forever

Install of forever fails on my ubuntu server with the following error;

npm info install failed rolled back
npm ERR! Error: [email protected] preinstall: node-waf configure build
npm ERR! sh "-c" "node-waf configure build" failed with 127
npm ERR! at ChildProcess. (/root/local/node/lib/node/.npm/npm/0.3.18/package/lib/utils/exec.js:49:20)
npm ERR! at ChildProcess.emit (events.js:67:17)
npm ERR! at ChildProcess.onexit (child_process.js:192:12)
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the daemon package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls daemon
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.38-linode31
npm ERR! argv { remain:
npm ERR! argv [ 'forever',
npm ERR! argv 'async@>= 0.1.8',
npm ERR! argv 'colors@>= 0.3.0',
npm ERR! argv 'daemon@>= 0.3.0',
npm ERR! argv 'optimist@>= 0.0.6',
npm ERR! argv 'timespan@>= 2.0.0',
npm ERR! argv 'vows@>= 0.5.2',
npm ERR! argv 'winston@>= 0.2.1',
npm ERR! argv 'vows@>= 0.5.2',
npm ERR! argv 'eyes@>=0.1.6',
npm ERR! argv 'colors@>= 0.3.0',
npm ERR! argv 'eyes@>= 0.1.6',
npm ERR! argv 'loggly@>= 0.1.4',
npm ERR! argv 'vows@>= 0.5.2',
npm ERR! argv 'request@>= 1.9.0' ],
npm ERR! argv cooked: [ 'install', 'forever' ],
npm ERR! argv original: [ 'install', 'forever' ] }
npm not ok

forever list (in 0.4.2)

Hey guys,

I'm finding that forever list isn't listing all my running forever processes. ps aux | grep forever will show extra processes...thoughts?

Cannot find module 'eyes' error is back

I see this issue was fixed a while back, but it seems to have returned. I'm using Node 0.4.5 and Forever 0.4.1. Here's the raw error:

node.js:134
    throw e; // process.nextTick error, or 'error' event on first tick
    ^
Error: Cannot find module 'eyes'
    at Function._resolveFilename (module.js:320:11)
    at Function._load (module.js:266:25)
    at require (module.js:348:19)
    at Object.<anonymous> (/usr/local/lib/node/.npm/forever/0.4.1/package/bin/forever:5:12)
    at Module._compile (module.js:404:26)
    at Object..js (module.js:410:10)
    at Module.load (module.js:336:31)
    at Function._load (module.js:297:12)
    at Array.<anonymous> (module.js:423:10)
    at EventEmitter._tickCallback (node.js:126:26)

I have to apologize - normally I'd just fix this sort of thing and submit a pull request but I'm a node newb. I'll dig in there and see if it's something I can just take care of when I have free time.

restart when files change?

I'm currently using Forever to manage my website node processes. And since I use git to maintain my code, I had taken a peak at Supervisor which monitors code changes. Gotta say it would be awesome to simply git push and have the forever processes restart.

If this is a dumb request (or asked before) please nevermind this and close the issue. Nevertheless thanks for listening :)

npm not killing

I think I'm running 0.5.2, I just reinstalled node and npm and forever.

Problem:

/home/ec2-user/node_modules/.bin/forever stopall && rm -rf /tmp/forever
/home/ec2-user/node_modules/.bin/forever cleanlogs

....Seems to kill all instances of forever, but it used to kill the actual node instance as well (the thing that my forever command started).

Now... (after the update) it appears it is not.

So.... After the above two statements, I need to do:

killall -9 node

....Can you tell me if I'm missing something? Thank you.

Joe

send email etc.

it would be very useful to be able to do certain things upon restart ... e.g. save the exception stack to exceptions.log, and send a tweet/email etc. (great project btw)

Missing module "winston"

I just tried to install forever on a new machine via npm and got the following error:

node.js:116
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Cannot find module 'winston'
    at Function._resolveFilename (module.js:289:11)
    at Function._load (module.js:241:25)
    at require (module.js:317:19)
    at Object.<anonymous> (/home/ubuntu/local/node/lib/node/.npm/forever/0.4.0/package/bin/forever:6:15)
    at Module._compile (module.js:373:26)
    at Object..js (module.js:379:10)
    at Module.load (module.js:305:31)
    at Function._load (module.js:271:10)
    at Array.<anonymous> (module.js:392:10)
    at EventEmitter._tickCallback (node.js:108:26)

Forever just started throwing errors

Help please! I just restarted forever (for some unrelated reason) and saw I'm getting these errors!!

Note: I just updated to 0.4.2 but only After I saw these errors. I do not believe I was getting these errors earlier today but I suppose it's possible. I certainly wasn't getting them for too long though or I would have seen them.

Note: my node.js script seems to be running fine right now even though I'm getting these errors. But something is wrong.

Please advise. Thanks.

.....

node.js:203
          process._kill(pid, startup.lazyConstants()[sig]);
                  ^
Error: ESRCH, No such process
    at EventEmitter.kill (node.js:203:19)
    at /home/jbob2/local/node/lib/node/.npm/forever/0.4.2/package/lib/forever                                                                       .js:150:15
    at Array.forEach (native)
    at Object.stop (/home/jbob2/local/node/lib/node/.npm/forever/0.4.2/packag                                                                       e/lib/forever.js:149:11)
    at EventEmitter. (/home/jbob2/local/node/lib/node/.npm/forever                                                                       /0.4.2/package/bin/forever:172:30)
    at EventEmitter.emit (events.js:39:17)
    at /home/jbob2/local/node/lib/node/.npm/forever/0.4.2/package/lib/forever                                                                       .js:334:21
    at /home/jbob2/local/node/lib/node/.npm/forever/0.4.2/package/lib/forever                                                                       .js:398:21
    at ChildProcess.exithandler (child_process.js:85:7)
    at ChildProcess.emit (events.js:45:17)

node.js:116
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Cannot call method 'split' of undefined
    at /home/jbob2/local/node/lib/node/.npm/forever/0.4.2/package/lib/forever                                                                       .js:357:80
    at Array.map (native)
    at Object.cleanLogsSync (/home/jbob2/local/node/lib/node/.npm/forever/0.4                                                                       .2/package/lib/forever.js:357:44)
    at Object.cleanUp (/home/jbob2/local/node/lib/node/.npm/forever/0.4.2/pac                                                                       kage/lib/forever.js:309:26)
    at Object. (/home/jbob2/local/node/lib/node/.npm/forever/0.4.2                                                                       /package/bin/forever:153:20)
    at Module._compile (module.js:374:26)
    at Object..js (module.js:380:10)
    at Module.load (module.js:306:31)
    at Function._load (module.js:272:10)
    at Array. (module.js:393:10)
/home/jbob2/local/node/bin/node: no process killed
/home/jbob2/local/node/nodescript.js: no process killed
/home/jbob2/local/node/temp.js: No such file or directory

error time on 0.4.1 (node)

root@yumoov:/u/apps/64sq-staging# forever stop boot
info: Forever processing arguments arg=boot
info: Running action: stop

node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'filter' of null
at Object.findByScript (/usr/local/lib/node/.npm/forever/0.4.1/package/lib/forever.js:234:20)
at Object.stop (/usr/local/lib/node/.npm/forever/0.4.1/package/lib/forever.js:146:46)
at EventEmitter. (/usr/local/lib/node/.npm/forever/0.4.1/package/bin/forever:173:30)
at EventEmitter.emit (events.js:39:17)
at Array. (/usr/local/lib/node/.npm/forever/0.4.1/package/lib/forever.js:342:15)
at EventEmitter._tickCallback (node.js:108:26)

Forever list not working

re-adding this issue as issue #37 was closed for some reason.
I'm running node 0.4.3, npm 0.3.17 and forever 0.4.1 on Mac OS 10.6.6
"forever start xxxxx.js" appears to work and the node process is started, the foreverXXX.log file gets created in /tmp/forever/ but "forever list" finds no process and nothing gets written to the log.
No data is being written to /tmp/forever/pids/xxxx.fvr, so even though the pid files are there forever thinks they are dead processes.
Have tried removing /tmp/forever but the result is the same.

support for coffeescript ?

i've got an app written in coffeescript, is there anyway I can use forever to launch it/keep it alive ?

Scripts started within node with different options replaces existing script process

I have a node script that takes an argument that's used to configure the running of the script.

forever script.js --option=1
forever script.js --option=2

From the command line, forever will span two different process. However, if I call them from within another node script, it replaces the first instance with the new instance.

var child1 = new (forever.Forever)('script.js', { 'options': [ "--option=1"] });
child1.start();
var child2 = new (forever.Forever)('script.js', { 'options': [ "--option=2"] });
child2.start();

This will result in only one process running, configured with option=2

Is there a way to span multiple process based on their options configuration from within node?

Daemon issue: undefined symbol: ev_default_fork

First off, thanks for forever, I've been using it for months with no problems whatsoever. I just updated to 0.4.0 and now I'm getting this error. I tried to repro on my mac, but I couldn't. What could be going on? Should I just re-image the machine and try again?

Thanks,
David

$ forever start hackharder.js 
node: symbol lookup error:     /usr/local/lib/node/.npm/daemon/0.3.0/package/build/default/daemon.node: undefined symbol: ev_default_fork
$ node --version
v0.4.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.1 LTS
Release:    10.04
Codename:   lucid

Set interval between restarts

Hello,
I would like to be able to set a timeout between consecutive restarts of my scripts by forever. Is there a way to do that? Also, I want some programming interface (like what God does - provides a ruby based DSL) so that relatively more complex operations can be performed. Is this something that is being considered?

unable to install with npm

Here's the log. It wants a version of vows greater than 0.5.2, and the default npm install of vows is only 0.5.0

$ npm install forever
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info fetch http://registry.npmjs.org/forever/-/forever-0.3.1.tgz
npm info calculating sha1 /tmp/npm-1297293169898/1297293169898-0.5912692858837545/tmp.tgz
npm info shasum 15a137663a63e582ff84781126045d8f17dc4d6b
npm info calculating sha1 /usr/local/lib/node/.npm/.cache/forever/0.3.1/package.tgz
npm info shasum 2f1a525c139f86ac7bd84b0609d2bd2cdf3cda75
npm info range colors@>= 0.3.0
npm info fetch http://registry.npmjs.org/colors/-/colors-0.3.0.tgz
npm info calculating sha1 /usr/local/lib/node/.npm/.cache/colors/0.3.0/package.tgz
npm info shasum 406c7460ea5e5f633c3db4c168983012dab99f37
npm info range daemon@>= 0.1.0
npm info fetch http://registry.npmjs.org/daemon/-/daemon-0.1.0.tgz
npm info calculating sha1 /usr/local/lib/node/.npm/.cache/daemon/0.1.0/package.tgz
npm info shasum d60bc3934a7399aaefcc1f0b09ed04ffe6b16ff9
npm info latest = [email protected] not supported by [email protected]
npm info range vows@>= 0.5.2
npm ERR! Error: No satisfying version found for 'vows'@'>=0.5.2'
npm ERR! Valid install targets for vows: "latest", "0.2.5", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.4.0", "0.4.1", "0.4.2", "0.4.3", "0.4.4", "0.4.5", "0.4.6", "0.5.0"
npm ERR! at /usr/local/lib/node/.npm/npm/0.2.17/package/lib/install.js:143:29
npm ERR! at /usr/local/lib/node/.npm/npm/0.2.17/package/lib/install.js:178:5
npm ERR! at /usr/local/lib/node/.npm/npm/0.2.17/package/lib/utils/registry/get.js:55:5
npm ERR! at /usr/local/lib/node/.npm/npm/0.2.17/package/lib/utils/registry/request.js:37:10
npm ERR! at IncomingMessage. (/usr/local/lib/node/.npm/npm/0.2.17/package/lib/utils/registry/request.js:174:14)
npm ERR! at IncomingMessage.emit (events:41:20)
npm ERR! at HTTPParser.onMessageComplete (http:107:23)
npm ERR! at Client.onData as ondata
npm ERR! at IOWatcher.callback (net:494:29)
npm ERR! at node.js:773:9
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to [email protected]
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok

Forever losing track for daemon processes on start

Let me start off with saying thanks for the great project, it has the promise of providing a very simple and clean solution to process management with the cli and api. I've recently integrated forever into a project that I'm working as a tool to help me kick off daemons and subsequently track and stop them. What I'm seeing is that on occasion forever will lose track of a spawned process on start. When I run into this situation I'm noticing that I have a .pid file without a matching .fvr file. When this occurs the process refered to by the .pid file is actually running but since there isn't a .fvr file forever is oblivious to its existence.

I want to, as briefly as I can, explain my usage to ensure that isn't the real issue. I'm kicking off forever processes using child-process.spawn, in effect I'm simply using the forever cli. Subsequently I do use the forever API in my script to list, stopAll and cleanUp. In this situations I first load the forever environment setting the path to be the default, namely /tmp/forever.

I'm just curious if anyone else is experiencing this (I'm on os x 10.6.6) or if there is something blatantly wrong with the code.

spawn code:

spawn 'forever', [
  'start'
  '/usr/local/bin/coffee'
  '/usr/local/bin/zappa'
  '-p'
  port
  'app/app.coffee' 
]    

spawn 'forever', [
  'start'
  '/usr/local/bin/coffee'
  'lib/proxy.coffee' 
  @port
  @appPort
] 

load code (not really relevant as the cli behaves the same as the api when the problem arises)

load = (callback) -> 
  forever.load(path: join 'tmp', 'forever').on 'load', -> callback()

Again the issue only comes up once and a while. I'm guessing that something is going wrong with the underlying daemon code and forever.save isn't being called. Just shooting from the hip though. Any thoughts to help me through this would be appreciated. Going to give it one more go this evening.

installing forever in the right place...

I have successfully installed forever on several Ubuntu 10.10 machines. While I am not too familiar with npm installs, It was easy!
Now I'm stumped... I have an ec2 instance running Ubuntu 10.10, node runs my app just fine. When I use the same steps I used previously to install forever, I end up with forever installed in a "node_modules" folder in my home or roots directory depending on how I'm logged in during the install...

I am able to launch my app with forever but "path" and "source" parameters are a pain to type and I have had my app crash with out a forever restart and I suspect it has to do with where it is installed.

I love the way forever is working for me on previous installs.

What have I done wrong on this one?

package.json missing dependency: eyes

I've just updated to forever 0.5.0 and when I run $ 'forever' I'm getting Error: Cannot find module 'eyes'. I've installed it in the forever folder with npm install eyes and everything is working, but so that you know :)

reboot and credentials

Scripts for upstart and similar to ensure haibu servers restarts on reboot

  • ability to add specific user credential in which to run applications (umask).
  • apparently related to the forever module used by haibu.

Possibly also a configurable way to apply some application restart policy.

  • but could also be separate - like an upstart dependency on haibu and various databases before running script to start app on haibu.

It doesn't work under Mac OS X 10.6.6. Should it?

log file example:
/usr/local/bin/node:1
����
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (node.js:458:37)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at Object.runMain (node.js:522:24)
at Array.0 (node.js:756:12)
at EventEmitter._tickCallback (node.js:55:22)
at node.js:768:9
Forever detected script exited with code: 1
Forever restarting script for 2020 time

my user can't run forever

when I... forever start bootstrap.js
I get a permission denied...
Error: EACCES, Permission denied '/tmp/forever/foreverfpO.log'

however I can... sudo forever start bootstrap.js

I did a chmod 777 on /tmp/forever and /tmp/forever/pids
that seems to have got me working for the time being. Is this ok?

I want to run my node app as an under-privileged user.
(this user can run my app... ie: node bootstrap.js)

Thanks!

optional script name

hey - sometimes i run my node stuff with 'spark' . It would be useful to be able to use forever here.

Absolute Path for Log Files

When you specify an absolute path for a log file, such as /app/logs/l.log, it seems that Forever wants to log to /tmp/forever/app/logs/l.log.

Seems broken in node v0.4.0

Tested in on Mac OSX Snow Leopard and Ubuntu Maverick

If I am running on node v0.4.0 and I say

$ forever start server.js

nothing gets started, so if I run

$ forever list

I get

> No forever processes running

forever list after forever stopall

Following scenario: One node app is running with forever.
Then you run "forever stopall". The app stops.

If you now run "forever list" the app still shows a running state. Only if you run "forever list" once more you get the info that no app is running.

vows

Hi,

Installing forever on 0.2.6 fails because vows's latest version is no longer supporting 0.2.X releases. I suggest completely removing vows from the package.json because testing packages shouldn't be included at all. Or specify a version of vows that does work with node v.0.2.X releases.

See error:

    npm info it worked if it ends with ok
    npm info using [email protected]
    npm info using [email protected]
    npm info range colors@>= 0.3.0
    npm info range daemon@>= 0.1.0
    npm info latest = [email protected] not supported by [email protected]
    npm info range vows@>= 0.5.2
    npm ERR! Error: No satisfying version found for 'vows'@'>=0.5.2'
    npm ERR! Valid install targets for vows: "latest", "0.2.5", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.4.0", "0.4.1", "0.4.2", "0.4.3", "0.4.4", "0.4.5", "0.4.6", "0.5.0"
    npm ERR!     at /usr/local/lib/node/.npm/npm/0.2.16/package/lib/install.js:143:29
    npm ERR!     at /usr/local/lib/node/.npm/npm/0.2.16/package/lib/install.js:178:5
    npm ERR!     at /usr/local/lib/node/.npm/npm/0.2.16/package/lib/utils/registry/get.js:55:5
    npm ERR!     at /usr/local/lib/node/.npm/npm/0.2.16/package/lib/utils/registry/request.js:37:10
    npm ERR!     at IncomingMessage.<anonymous> (/usr/local/lib/node/.npm/npm/0.2.16/package/lib/utils/registry/request.js:174:14)
    npm ERR!     at IncomingMessage.emit (events:48:20)
    npm ERR!     at HTTPParser.onMessageComplete (http:107:23)
    npm ERR!     at Client.onData [as ondata] (http:854:27)
    npm ERR!     at IOWatcher.callback (net:494:29)
    npm ERR!     at node.js:773:9
    npm ERR! Report this *entire* log at <http://github.com/isaacs/npm/issues>
    npm ERR! or email it to <[email protected]>
    npm ERR! Just tweeting a tiny part of the error will not be helpful.

error on npm install 4.0 Cannot find module 'eyes'

Just tried to update to 4.0 OS X 10.6.6 using npm got the following error. Error encountered on two os x machines.

node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'eyes'
at Function._resolveFilename (module.js:289:11)
at Function._load (module.js:241:25)
at require (module.js:317:19)
at Object. (/opt/local/lib/node/.npm/forever/0.4.0/package/bin/forever:5:12)
at Module._compile (module.js:373:26)
at Object..js (module.js:379:10)
at Module.load (module.js:305:31)
at Function._load (module.js:271:10)
at require (module.js:317:19)
at Object. (/opt/local/bin/[email protected]:11:18)

Stoppping a process with a path.

Right now you pass in an index
forever stop 0

To kill a process. It would be nice when writing scripts to have the ability to pass in a path as well. e.g.
forever start /path/to/myapp.js
forever stop /path/to/myapp.js

Since I'm not sure what index it is, I just know I want to stop that program. Thoughts?

Option to restart daemons

We're running multiple instances of a exactly same server with forever
and it would be great if I could use forever to simply restart one of them.
Here's an example how it could look

[root@machine ~]# forever list
[0] server.js [ 14887, 14885 ]
[1] server.js [ 31055, 31054 ]
[2] server.js [ 31019, 31018 ]
[3] server.js [ 31033, 31032 ]
[4] server.js [ 31079, 31078 ]
[5] server.js [ 19575, 19574 ]
[6] server.js [ 14949, 14948 ]

[root@machine ~]# forever restart 0
Restarted [0] server.js

Also another neat feature would be to store the startup time to the
.fvr file so it could show uptimes:

[root@machine ~]# forever list
[0] server.js [ 14887, 14885 ] 1 min 12 secs
[1] server.js [ 31055, 31054 ] 7 hours 40 mins
[2] server.js [ 31019, 31018 ] 7 hours 40 mins
[3] server.js [ 31033, 31032 ] 7 hours 41 mins
[4] server.js [ 31079, 31078 ] 7 hours 41 mins
[5] server.js [ 19575, 19574 ] 7 hours 41 mins
[6] server.js [ 14949, 14948 ] 7 hours 41 mins

Also even better if I could order a rolling restart so each instance
is restarted sequentially:

[root@machine ~]# forever rollingrestart
Restarting 7 instances of server.js.......done.

Restarting doesn't remember options

I'm setting a out file like forever -o out.log server.js

When I call forever restart server.js, it logs to a different file from out.log.

I've also tried forever restart -o out.log server.js, but that didn't work either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.