forked from strongloop/microgateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 974 Bytes
/
index.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
// © Copyright IBM Corporation 2016,2017.
// Node module: microgateway
// LICENSE: Apache 2.0, https://www.apache.org/licenses/LICENSE-2.0
'use strict';
var path = require('path');
var YAML = require('yamljs');
var logger = require('apiconnect-cli-logger/logger.js')
.child({ loc: 'microgateway:index' });
var env = {
NODE_ENV: 'production',
APIMANAGER_CATALOG: '',
APIMANAGER_PORT: 443,
APIMANAGER_REFRESH_INTERVAL: 15 * 1000 * 60 };
try {
var envjson = YAML.load(path.join(__dirname, '/env.yaml'));
Object.keys(envjson).forEach(function(k) {
env[k] = envjson[k];
});
} catch (e) {
logger.info('Fail to load environment variables: ', e);
}
Object.keys(env).forEach(function(k) {
// Don't override env variables that were set explicitly
if (typeof process.env[k] === 'undefined') {
process.env[k] = env[k];
}
});
// Should we do any extra sanity checks here?
require('./lib/microgw.js').start(process.env.PORT);