-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (40 loc) · 829 Bytes
/
index.js
File metadata and controls
50 lines (40 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Module dependencies.
*/
var Group = require('./lib/group');
/**
* Expose `Group`.
*/
exports = module.exports = Group;
/**
* Parse configuration `str`.
*
* @param {String} str
* @return {Object}
* @api public
*/
exports.parseConfig = function(str){
var conf = {};
conf.processes = {};
str.split(/\r?\n/).forEach(function(line){
if ('' == line.trim()) return;
if (/^ *#/.test(line)) return;
var i = line.indexOf('=');
var key = line.slice(0, i).trim();
var val = line.slice(i + 1).trim();
switch (key) {
case 'logs':
case 'pids':
case 'on-error':
case 'on-restart':
case 'sleep':
case 'attempts':
case 'prefix':
conf[key] = val;
break;
default:
conf.processes[key] = val;
}
});
return conf;
};