Skip to content

Commit d3bbbef

Browse files
committed
usage info
1 parent 38baf94 commit d3bbbef

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

README.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,74 @@ Simply doing an child_process.**exec** per command to launch an external process
1313

1414
The diagram below should conceptually give you an idea of what this module does.
1515

16-
**The local user that the node process runs as should have virtually zero rights! Also be sure to properly configure a restricted UID/GID when instatiating a new instance of this**
16+
**The local user that the node process runs as should have virtually zero rights! Also be sure to properly configure a restricted UID/GID when instatiating a new instance of this. See security notes below.**
1717

1818
![Alt text](/diagram.png "Diagram1")
1919

2020
### Usage
2121

22-
Its highly recommended you check out the unit-tests for some examples in addition to the below:
22+
To use StatefulProcessCommandProxy the constructor takes one parameter which is a configuration object who's properties are described below. Please refer to the example (following) and the unit-test for more details.
23+
24+
```
25+
name: The name of this instance, arbitrary
26+
27+
max: maximum number of processes to maintain
28+
29+
min: minimum number of processes to maintain
30+
31+
idleTimeoutMS: idle in milliseconds by which a process will be destroyed
32+
33+
processCommand: full path to the actual process to be spawned (i.e. /bin/bash)
34+
35+
processArgs: arguments to pass to the process command
36+
37+
processRetainMaxCmdHistory: default 0, for each process spawned, the maximum number
38+
of command history objects to retain in memory
39+
(useful for debugging via the getStatus() method)
40+
41+
processInvalidateOnRegex: optional config of regex patterns who if match
42+
their respective type, will flag the process as invalid
43+
44+
{
45+
'any' : ['regex1', ....],
46+
'stdout' : ['regex1', ....],
47+
'stderr' : ['regex1', ....]
48+
}
49+
50+
processCwd: optional current working directory for the processes to be spawned
2351
52+
processEnvMap: optional hash/object of key-value pairs for environment variables
53+
to set for the spawned processes
54+
55+
processUid: optional uid to launch the processes as
56+
57+
processGid: optional gid to launch the processes as
58+
59+
logFunction: optional function that should have the signature
60+
(severity,origin,message), where log messages will
61+
be sent to. If null, logs will just go to console
62+
63+
initCommands: optional array of actual commands to execute on each newly
64+
spawned ProcessProxy in the pool before it is made available
65+
66+
preDestroyCommands: optional array of actual commands to execute on a process
67+
before it is killed/destroyed on shutdown or being invalid
68+
69+
validateFunction: optional function that should have the signature to accept
70+
a ProcessProxy object, and should return true/false if the
71+
process is valid or not, at a minimum this should call
72+
ProcessProxy.isValid(). If the function is not provided
73+
the default behavior is to only check ProcessProxy.isValid()
74+
which is sufficient for most use cases if 'processInvalidateOnRegex'
75+
is properly configured
76+
```
77+
78+
Its highly recommended you check out the unit-tests for some examples in addition to the below:
2479

2580
### Example
81+
82+
Note this example is for a machine w/ bash in the typical location. Windows (or other) can adjust the below as necessary to run).
83+
2684
```
2785
var Promise = require('promise');
2886
var StatefulProcessCommandProxy = require("./");

0 commit comments

Comments
 (0)