You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-25Lines changed: 31 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,11 +16,17 @@ A simple CLI tool for ensuring that a given script runs continuously (i.e. forev
16
16
```
17
17
18
18
## 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].
20
20
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).
@@ -92,18 +98,8 @@ There are [several examples][1] designed to test the fault tolerance of forever.
92
98
$ forever -m 5 examples/error-on-timer.js
93
99
```
94
100
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.
107
103
108
104
**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:
109
105
@@ -113,7 +109,7 @@ In addition to using a Forever object, the forever module also exposes some usef
113
109
114
110
This method takes multiple `forever.Monitor` instances which are defined in the `forever-monitor` dependency.
115
111
116
-
### forever.load (config)
112
+
####forever.load (config)
117
113
_Synchronously_ sets the specified configuration (config) for the forever module. There are two important options:
118
114
119
115
Option | Description | Default
@@ -126,40 +122,50 @@ columns | Array of columns to display when `format` is true | `forever.config.
126
122
debug | Boolean value indicating to run in debug mode | false
127
123
stream | Boolean value indicating if logs will be streamed | false
128
124
129
-
### forever.start (file, options)
125
+
####forever.start (file, options)
130
126
Starts a script with forever. The `options` object is what is expected by the `Monitor` of `forever-monitor`.
131
127
132
-
### forever.startDaemon (file, options)
128
+
####forever.startDaemon (file, options)
133
129
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`.
134
130
135
-
### forever.stop (index)
131
+
####forever.stop (index)
136
132
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.
137
133
138
-
### forever.stopAll (format)
134
+
####forever.stopAll (format)
139
135
Stops all forever scripts currently running. This method returns an EventEmitter that raises the 'stopAll' event when complete.
140
136
141
137
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')`.
142
138
143
-
### forever.list (format, callback)
139
+
####forever.list (format, callback)
144
140
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()`
145
141
146
142
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')`.
147
143
148
-
### forever.tail (target, options, callback)
144
+
####forever.tail (target, options, callback)
149
145
Responds with the logs from the target script(s) from `tail`. There are two options:
150
146
151
147
*`length` (numeric): is is used as the `-n` parameter to `tail`.
152
148
*`stream` (boolean): is is used as the `-f` parameter to `tail`.
153
149
154
-
### forever.cleanUp ()
150
+
####forever.cleanUp ()
155
151
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.
156
152
157
-
### forever.cleanLogsSync (processes)
153
+
####forever.cleanLogsSync (processes)
158
154
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`.
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.
162
158
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.
0 commit comments