forked from stfbohn/coopcycle-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpm2.config.js
80 lines (70 loc) · 1.74 KB
/
pm2.config.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var argv = require('minimist')(process.argv.slice(2));
var _ = require('lodash');
var ConfigLoader = require('./js/api/ConfigLoader');
var watchOptions = {
usePolling: true,
ignorePermissionErrors: true,
followSymlinks: false,
interval: 400
};
var env = argv.env || 'development';
var ROOT_DIR = __dirname;
var envMap = {
production: 'prod',
development: 'dev',
test: 'test'
};
try {
var configFile = 'config.yml';
if (envMap[env]) {
configFile = 'config_' + envMap[env] + '.yml';
console.log('Config file : ' + configFile);
} else {
console.log('No config file loaded');
}
var configLoader = new ConfigLoader(ROOT_DIR + '/app/config/' + configFile);
var config = configLoader.load();
} catch (e) {
throw e;
}
var appName = config.parameters['app.name'] || 'default';
var apps = [{
name: "coopcycle-dispatch-" + appName,
script: "./js/api/dispatch/index.js",
watch: ["./js/api/dispatch/index.js", "./js/api/models/*.js", "./js/api/*.js"],
port: config.parameters['app.dispatch_port'] || 8000
}, {
name: "coopcycle-tracking-" + appName,
script: "./js/api/tracking/index.js",
watch: ["./js/api/tracking/index.js", "./js/api/tracking/index.html"],
port: config.parameters['app.tracking_port'] || 8001
}];
apps = _.map(apps, function(app) {
if (env === 'production') {
delete app.watch;
app = _.extend(app, {
cwd: __dirname,
});
} else {
app = _.extend(app, {
watch_options: watchOptions
});
}
return _.extend(app, {
env: {
NODE_ENV: "development",
PORT: app.port,
},
env_production : {
NODE_ENV: "production",
PORT: app.port,
},
env_test : {
NODE_ENV: "test",
PORT: app.port,
}
});
});
module.exports = {
apps: apps
};