-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
52 lines (47 loc) · 1.65 KB
/
Copy pathapp.js
File metadata and controls
52 lines (47 loc) · 1.65 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
'use strict';
const fs = require('fs');
const express = require('express');
const http = require('http');
const https = require('https');
const log4js = require('log4js');
const config = require('./config/config');
const db = require('./app/database/connection');
const datapool = require('./app/datapool');
const cron = require('./app/cron');
db.connect(config);
datapool.initialize(config);
require('./config/passport')(config);
const app = express();
require('./config/log')(null, config);
require('./config/i18n')(app, config);
require('./config/express')(app, config);
require('./config/routes/')(app, config);
/**
* App launch
*/
if (!module.parent) {
const logger = log4js.getLogger();
http.createServer(app).listen(process.env.PORT || config.port);
logger.info('============ Comunidad de plantas ============');
logger.info('App started time', new Date());
logger.info('App started in port:', config.port);
logger.info('App started in env:', config.env);
logger.info('Node version:', process.version);
logger.info('App started with exec-arguments:', process.execArgv);
logger.info('App started with args:', process.argv.toString());
logger.info('App dependencies:', JSON.stringify(process.versions));
logger.info('--- HTTPS ----');
logger.info('disabled');
if (config.https) {
var options = {
key: fs.readFileSync(config.https.privateKey),
cert: fs.readFileSync(config.https.certificate),
};
https.createServer(options, app).listen(config.https.port);
logger.info('--- HTTPS ----');
logger.info('Listening port:', config.https.port);
} else {
logger.info('--- HTTPS ----');
logger.info('disabled');
}
}