1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var debug = require('debug')('pm2:conf');
|
8 | var p = require('path');
|
9 | var util = require('util');
|
10 | var chalk = require('chalk');
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | var path_structure = require('./paths.js')(process.env.OVER_HOME);
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | var csts = {
|
21 | PREFIX_MSG : chalk.green('[PM2] '),
|
22 | PREFIX_MSG_INFO : chalk.cyan('[PM2][INFO] '),
|
23 | PREFIX_MSG_ERR : chalk.red('[PM2][ERROR] '),
|
24 | PREFIX_MSG_MOD : chalk.bold.green('[PM2][Module] '),
|
25 | PREFIX_MSG_MOD_ERR : chalk.red('[PM2][Module][ERROR] '),
|
26 | PREFIX_MSG_WARNING : chalk.yellow('[PM2][WARN] '),
|
27 | PREFIX_MSG_SUCCESS : chalk.cyan('[PM2] '),
|
28 |
|
29 | PM2_IO_MSG : chalk.cyan('[PM2 I/O]'),
|
30 | PM2_IO_MSG_ERR : chalk.red('[PM2 I/O]'),
|
31 |
|
32 | TEMPLATE_FOLDER : p.join(__dirname, 'lib/templates'),
|
33 |
|
34 | APP_CONF_DEFAULT_FILE : 'ecosystem.config.js',
|
35 | APP_CONF_TPL : 'ecosystem.tpl',
|
36 | APP_CONF_TPL_SIMPLE : 'ecosystem-simple.tpl',
|
37 | SAMPLE_CONF_FILE : 'sample-conf.js',
|
38 | LOGROTATE_SCRIPT : 'logrotate.d/pm2',
|
39 |
|
40 | DOCKERFILE_NODEJS : 'Dockerfiles/Dockerfile-nodejs.tpl',
|
41 | DOCKERFILE_JAVA : 'Dockerfiles/Dockerfile-java.tpl',
|
42 | DOCKERFILE_RUBY : 'Dockerfiles/Dockerfile-ruby.tpl',
|
43 |
|
44 | SUCCESS_EXIT : 0,
|
45 | ERROR_EXIT : 1,
|
46 | CODE_UNCAUGHTEXCEPTION : 1,
|
47 |
|
48 | IS_WINDOWS : (process.platform === 'win32' || process.platform === 'win64' || /^(msys|cygwin)$/.test(process.env.OSTYPE)),
|
49 | ONLINE_STATUS : 'online',
|
50 | STOPPED_STATUS : 'stopped',
|
51 | STOPPING_STATUS : 'stopping',
|
52 | WAITING_RESTART : 'waiting restart',
|
53 | LAUNCHING_STATUS : 'launching',
|
54 | ERRORED_STATUS : 'errored',
|
55 | ONE_LAUNCH_STATUS : 'one-launch-status',
|
56 |
|
57 | CLUSTER_MODE_ID : 'cluster_mode',
|
58 | FORK_MODE_ID : 'fork_mode',
|
59 |
|
60 | LOW_MEMORY_ENVIRONMENT : process.env.PM2_OPTIMIZE_MEMORY || false,
|
61 |
|
62 | MACHINE_NAME : process.env.INSTANCE_NAME || process.env.MACHINE_NAME || process.env.PM2_MACHINE_NAME,
|
63 | SECRET_KEY : process.env.KEYMETRICS_SECRET || process.env.PM2_SECRET_KEY || process.env.SECRET_KEY,
|
64 | PUBLIC_KEY : process.env.KEYMETRICS_PUBLIC || process.env.PM2_PUBLIC_KEY || process.env.PUBLIC_KEY,
|
65 | KEYMETRICS_ROOT_URL : process.env.KEYMETRICS_NODE || process.env.PM2_APM_ADDRESS || process.env.ROOT_URL || process.env.INFO_NODE || 'root.keymetrics.io',
|
66 |
|
67 |
|
68 | PM2_BANNER : '../lib/motd',
|
69 | PM2_UPDATE : '../lib/API/pm2-plus/pres/motd.update',
|
70 | DEFAULT_MODULE_JSON : 'package.json',
|
71 |
|
72 | MODULE_BASEFOLDER: 'module',
|
73 | MODULE_CONF_PREFIX: 'module-db-v2',
|
74 | MODULE_CONF_PREFIX_TAR: 'tar-modules',
|
75 |
|
76 | EXP_BACKOFF_RESET_TIMER : parseInt(process.env.EXP_BACKOFF_RESET_TIMER) || 30000,
|
77 | REMOTE_PORT_TCP : isNaN(parseInt(process.env.KEYMETRICS_PUSH_PORT)) ? 80 : parseInt(process.env.KEYMETRICS_PUSH_PORT),
|
78 | REMOTE_PORT : 41624,
|
79 | REMOTE_HOST : 's1.keymetrics.io',
|
80 | SEND_INTERVAL : 1000,
|
81 | RELOAD_LOCK_TIMEOUT : parseInt(process.env.PM2_RELOAD_LOCK_TIMEOUT) || 30000,
|
82 | GRACEFUL_TIMEOUT : parseInt(process.env.PM2_GRACEFUL_TIMEOUT) || 8000,
|
83 | GRACEFUL_LISTEN_TIMEOUT : parseInt(process.env.PM2_GRACEFUL_LISTEN_TIMEOUT) || 3000,
|
84 | LOGS_BUFFER_SIZE : 8,
|
85 | CONTEXT_ON_ERROR : 2,
|
86 | AGGREGATION_DURATION : process.env.PM2_DEBUG || process.env.NODE_ENV === 'local_test' || process.env.NODE_ENV === 'development' ? 3000 : 5 * 60000,
|
87 | TRACE_FLUSH_INTERVAL : process.env.PM2_DEBUG || process.env.NODE_ENV === 'local_test' ? 1000 : 60000,
|
88 |
|
89 |
|
90 | CONCURRENT_ACTIONS : (function() {
|
91 | var concurrent_actions = parseInt(process.env.PM2_CONCURRENT_ACTIONS) || 2;
|
92 | debug('Using %d parallelism (CONCURRENT_ACTIONS)', concurrent_actions);
|
93 | return concurrent_actions;
|
94 | })(),
|
95 |
|
96 | DEBUG : process.env.PM2_DEBUG || false,
|
97 | WEB_IPADDR : process.env.PM2_API_IPADDR || '0.0.0.0',
|
98 | WEB_PORT : parseInt(process.env.PM2_API_PORT) || 9615,
|
99 | WEB_STRIP_ENV_VARS : process.env.PM2_WEB_STRIP_ENV_VARS || false,
|
100 | MODIFY_REQUIRE : process.env.PM2_MODIFY_REQUIRE || false,
|
101 |
|
102 | WORKER_INTERVAL : process.env.PM2_WORKER_INTERVAL || 30000,
|
103 | KILL_TIMEOUT : process.env.PM2_KILL_TIMEOUT || 1600,
|
104 | KILL_SIGNAL : process.env.PM2_KILL_SIGNAL || 'SIGINT',
|
105 | KILL_USE_MESSAGE : process.env.PM2_KILL_USE_MESSAGE || false,
|
106 |
|
107 | PM2_PROGRAMMATIC : typeof(process.env.pm_id) !== 'undefined' || process.env.PM2_PROGRAMMATIC,
|
108 | PM2_LOG_DATE_FORMAT : process.env.PM2_LOG_DATE_FORMAT !== undefined ? process.env.PM2_LOG_DATE_FORMAT : 'YYYY-MM-DDTHH:mm:ss'
|
109 |
|
110 | };
|
111 |
|
112 | module.exports = Object.assign(csts, path_structure);
|