forked from cnpm/cnpmjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.js
43 lines (37 loc) · 1.08 KB
/
worker.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
/**!
* cnpmjs.org - worker.js
*
* Copyright(c) cnpmjs.org and other contributors.
* MIT Licensed
*
* Authors:
* dead_horse <[email protected]>
* fengmk2 <[email protected]> (http://fengmk2.com)
*/
'use strict';
/**
* Module dependencies.
*/
var graceful = require('graceful');
var registry = require('./servers/registry');
var web = require('./servers/web');
var logger = require('./common/logger');
var config = require('./config');
registry.listen(config.registryPort, config.bindingHost);
web.listen(config.webPort, config.bindingHost);
console.log('[%s] [worker:%d] Server started, registry server listen at %s:%d, web listen at %s:%d, cluster: %s',
new Date(), process.pid,
config.bindingHost, config.registryPort,
config.bindingHost, config.webPort,
config.enableCluster);
graceful({
server: [registry, web],
error: function (err, throwErrorCount) {
if (err.message) {
err.message += ' (uncaughtException throw ' + throwErrorCount + ' times on pid:' + process.pid + ')';
}
console.error(err);
console.error(err.stack);
logger.error(err);
}
});