forked from sourabhagrawal/mypa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.js
More file actions
60 lines (55 loc) · 1.45 KB
/
launch.js
File metadata and controls
60 lines (55 loc) · 1.45 KB
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
var _ = require("underscore");
var settings = require("./settings");
console.log("************************")
console.log("Preparing launch...")
console.log("************************")
console.log("Configuring environment variables.");
/* Set NODE_ENV
* Checks if already set or passed as parameter.
* Defaults to dev
*/
var envs = ["dev", "preprod", "prod"];
if(! process.env.NODE_ENV) {
var env = process.argv[2];
if(! _.contains(envs, env) ) {
env = settings.env;
}
if(! _.contains(envs, env) ) {
env = "dev";
}
process.env.NODE_ENV = env;
console.log(">> setting : NODE_ENV = "+process.env.NODE_ENV);
} else {
console.log(">> found : NODE_ENV = "+process.env.NODE_ENV);
}
/*
* Set the NODE_CONFIG_DIR if not set
*/
if(! process.env.NODE_CONFIG_DIR) {
process.env.NODE_CONFIG_DIR = settings.root+"/configs";
console.log(">> setting : NODE_CONFIG_DIR = "+process.env.NODE_CONFIG_DIR);
} else {
console.log(">> found : NODE_CONFIG_DIR = "+process.env.NODE_CONFIG_DIR);
}
/*
* Load the application config and merge with settings
*/
CONFIG = require("config");
for(var key in settings) {
if(settings.hasOwnProperty(key)) {
CONFIG[key] = settings[key];
}
}
CONFIG["env"] = env;
/*
* Launch the application
*/
console.log("Launching app...");
var app = require("./app");
app.run(CONFIG.port);
/*
* Run the schedler
*/
console.log("Starting scheduler...");
var scheduler = require('./services/scheduler');
scheduler.run();