Skip to content

Commit 31c2f16

Browse files
author
Doug Carroll
committed
Remove overwhelm, highlight forever start in doc
1 parent 00df57e commit 31c2f16

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

README.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@ A simple CLI tool for ensuring that a given script runs continuously (i.e. forev
1616
```
1717

1818
## Usage
19-
There are two distinct ways to use forever: through the command line interface, or by requiring the forever module in your own code. **Note:** If you are using forever _programatically_ you should install [forever-monitor][0].
19+
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][0].
2020

21-
### Using forever from the command line
22-
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:
21+
### Command Line Usage
22+
You can use forever to run scripts continuously (whether it is written in node.js or not).
2323

24+
**Example**
25+
```
26+
forever start app.js
27+
```
28+
29+
**Options**
2430
```
2531
$ forever --help
2632
usage: forever [action] [options] SCRIPT [script-options]
@@ -92,18 +98,8 @@ There are [several examples][1] designed to test the fault tolerance of forever.
9298
$ forever -m 5 examples/error-on-timer.js
9399
```
94100

95-
### Changing where forever writes files
96-
97-
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:
98-
99-
```
100-
FOREVER_ROOT=/etc/forever forever start index.js
101-
```
102-
103-
Make sure that the user running the process has the appropriate privileges to read & write to this directory.
104-
105-
## Using forever module from node.js
106-
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][2] for sample usage.
101+
### Using In Your Code
102+
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][2] for sample usage.
107103

108104
**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:
109105

@@ -113,7 +109,7 @@ In addition to using a Forever object, the forever module also exposes some usef
113109

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

116-
### forever.load (config)
112+
#### forever.load (config)
117113
_Synchronously_ sets the specified configuration (config) for the forever module. There are two important options:
118114

119115
Option | Description   | Default
@@ -126,40 +122,50 @@ columns | Array of columns to display when `format` is true | `forever.config.
126122
debug | Boolean value indicating to run in debug mode | false
127123
stream | Boolean value indicating if logs will be streamed | false
128124

129-
### forever.start (file, options)
125+
#### forever.start (file, options)
130126
Starts a script with forever. The `options` object is what is expected by the `Monitor` of `forever-monitor`.
131127

132-
### forever.startDaemon (file, options)
128+
#### forever.startDaemon (file, options)
133129
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`.
134130

135-
### forever.stop (index)
131+
#### forever.stop (index)
136132
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.
137133

138-
### forever.stopAll (format)
134+
#### forever.stopAll (format)
139135
Stops all forever scripts currently running. This method returns an EventEmitter that raises the 'stopAll' event when complete.
140136

141137
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')`.
142138

143-
### forever.list (format, callback)
139+
#### forever.list (format, callback)
144140
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()`
145141

146142
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')`.
147143

148-
### forever.tail (target, options, callback)
144+
#### forever.tail (target, options, callback)
149145
Responds with the logs from the target script(s) from `tail`. There are two options:
150146

151147
* `length` (numeric): is is used as the `-n` parameter to `tail`.
152148
* `stream` (boolean): is is used as the `-f` parameter to `tail`.
153149

154-
### forever.cleanUp ()
150+
#### forever.cleanUp ()
155151
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.
156152

157-
### forever.cleanLogsSync (processes)
153+
#### forever.cleanLogsSync (processes)
158154
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`.
159155

160-
### forever.startServer (monitor0, monitor1, ..., monitorN)
156+
#### forever.startServer (monitor0, monitor1, ..., monitorN)
161157
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.
162158

159+
### Logging and output file locations
160+
161+
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:
162+
163+
```
164+
FOREVER_ROOT=/etc/forever forever start index.js
165+
```
166+
167+
Make sure that the user running the process has the appropriate privileges to read & write to this directory.
168+
163169
## Run Tests
164170

165171
``` bash

0 commit comments

Comments
 (0)