Skip to content
This repository was archived by the owner on Feb 4, 2020. It is now read-only.

Commit c4cae3d

Browse files
committed
pm2 base configuration
1 parent 32c3c98 commit c4cae3d

File tree

1 file changed

+49
-54
lines changed

1 file changed

+49
-54
lines changed

bin/www

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,60 @@ var Server = require('../api/server')
66
var http = require('http')
77
var url = require('url')
88
var blocked = require('blocked')
9-
var throng = require('throng')
109
const logging = require('../api/lib/logging')
1110

12-
var NB_WORKERS = nconf.get('nbWorkers')
11+
const logger = logging.createLogger(nconf, 'api-particulier')
1312

14-
throng(NB_WORKERS, function (id) {
15-
const logger = logging.createLogger(nconf, id)
16-
17-
blocked((ms) => {
18-
logger.debug('BLOCKED for %dms!', ms)
19-
})
13+
blocked((ms) => {
14+
logger.debug('BLOCKED for %dms!', ms)
15+
})
2016

21-
var mhttp = require('http-measuring-client').create()
22-
mhttp.mixin(http)
23-
mhttp.on('stat', function (parsed, stats) {
24-
if (url.format(parsed).includes(nconf.get('es:host'))) {
25-
return
26-
}
27-
logger.info({
28-
parsedUri: parsed,
29-
stats: stats
30-
}, '%s %s took %d/%dms (%d)', stats.method || 'GET', url.format(parsed), stats.connectionTime, stats.totalTime, stats.statusCode)
31-
})
17+
var mhttp = require('http-measuring-client').create()
18+
mhttp.mixin(http)
19+
mhttp.on('stat', function (parsed, stats) {
20+
if (url.format(parsed).includes(nconf.get('es:host'))) {
21+
return
22+
}
23+
logger.info({
24+
parsedUri: parsed,
25+
stats: stats
26+
}, '%s %s took %d/%dms (%d)', stats.method || 'GET', url.format(parsed), stats.connectionTime, stats.totalTime, stats.statusCode)
27+
})
3228

33-
var server = new Server({
34-
port: nconf.get('PORT'),
35-
cafHost: nconf.get('cafHost'),
36-
svairHost: nconf.get('svairHost'),
37-
cafStub: nconf.get('cafStub'),
38-
cafSslCertificate: nconf.get('cafSslCertificate'),
39-
cafSslKey: nconf.get('cafSslKey'),
40-
mongoDbUrl: nconf.get('mongoDbUrl'),
41-
tokenService: nconf.get('tokenService'),
42-
mockIntrospect: nconf.get('mockIntrospect'),
43-
cafPingParams: {
44-
numeroAllocataire: nconf.get('numeroAllocataire'),
45-
codePostal: nconf.get('codePostal')
46-
},
47-
logger: logger,
48-
numeroFiscal: nconf.get('numeroFiscal'),
49-
referenceAvis: nconf.get('referenceAvis'),
50-
codePostal: nconf.get('codePostal'),
51-
tokensPath: nconf.get('tokensPath'),
29+
var server = new Server({
30+
port: nconf.get('PORT'),
31+
cafHost: nconf.get('cafHost'),
32+
svairHost: nconf.get('svairHost'),
33+
cafStub: nconf.get('cafStub'),
34+
cafSslCertificate: nconf.get('cafSslCertificate'),
35+
cafSslKey: nconf.get('cafSslKey'),
36+
mongoDbUrl: nconf.get('mongoDbUrl'),
37+
tokenService: nconf.get('tokenService'),
38+
mockIntrospect: nconf.get('mockIntrospect'),
39+
cafPingParams: {
5240
numeroAllocataire: nconf.get('numeroAllocataire'),
53-
nconf: nconf,
54-
raven: {
55-
activate: nconf.get('raven:activate'),
56-
dsn: nconf.get('raven:dsn')
57-
},
58-
ban: {
59-
baseUrl: nconf.get('ban:baseUrl')
60-
}
61-
})
41+
codePostal: nconf.get('codePostal')
42+
},
43+
logger: logger,
44+
numeroFiscal: nconf.get('numeroFiscal'),
45+
referenceAvis: nconf.get('referenceAvis'),
46+
codePostal: nconf.get('codePostal'),
47+
tokensPath: nconf.get('tokensPath'),
48+
numeroAllocataire: nconf.get('numeroAllocataire'),
49+
nconf: nconf,
50+
raven: {
51+
activate: nconf.get('raven:activate'),
52+
dsn: nconf.get('raven:dsn')
53+
},
54+
ban: {
55+
baseUrl: nconf.get('ban:baseUrl')
56+
}
57+
})
6258

63-
server.start(function (err) {
64-
if (err) {
65-
logger.fatal({error: err}, 'cannot recover from previous errors. shutting down now. error was', err.stack)
66-
setTimeout(process.exit.bind(null, 99), 10)
67-
}
68-
logger.info('Sever successfully started.')
69-
})
59+
server.start(function (err) {
60+
if (err) {
61+
logger.fatal({error: err}, 'cannot recover from previous errors. shutting down now. error was', err.stack)
62+
setTimeout(process.exit.bind(null, 99), 10)
63+
}
64+
logger.info('Sever successfully started.')
7065
})

0 commit comments

Comments
 (0)