-
Notifications
You must be signed in to change notification settings - Fork 224
/
setup.js
65 lines (56 loc) · 2.4 KB
/
setup.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
/* global process */
/*******************************************************************************
* Copyright (c) 2015 IBM Corp.
*
* All rights reserved.
*
* This app will run in one of 3 environments:
* 1. Bluemix Production
* 2. Bluemix Development
* 3. Localhost Development
*
* This file will export objects including the port that the application should
* listen on. If the application is running on the localhost, port 3000 will be
* used.
*
* Contributors:
* David Huffman - Initial implementation
*******************************************************************************/
var TAG = 'SETUP.JS: ';
var vcap_app = {application_uris: ['']};
var ext_uri = '';
////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// 1. Bluemix Production ////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
if (process.env.VCAP_APPLICATION) {
console.log(TAG + 'This app is running in Bluemix.');
vcap_app = JSON.parse(process.env.VCAP_APPLICATION);
for (var i in vcap_app.application_uris) {
if (vcap_app.application_uris[i].indexOf(vcap_app.name) >= 0) {
ext_uri = vcap_app.application_uris[i];
}
}
exports.SERVER = {
HOST: process.env.VCAP_APP_HOST || '0.0.0.0',
PORT: process.env.VCAP_APP_PORT || process.env.PORT,
DESCRIPTION: 'Bluemix - Production',
EXTURI: ext_uri
};
}
////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// 2. Localhost - Development ////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
else {
console.log(TAG + 'Assuming this app is running on localhost.');
exports.SERVER = {
HOST: 'localhost',
PORT: 3000,
DESCRIPTION: 'Localhost',
EXTURI: process.env.EXTURI || 'localhost:3000'
};
}
exports.SERVER.vcap_app = vcap_app;
////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////// Common ////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
exports.DEBUG = vcap_app;