-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dotos
committed
Oct 23, 2016
1 parent
1c9a274
commit f03b088
Showing
13 changed files
with
507 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var cluster = require('cluster'); | ||
cluster.setupMaster({ | ||
exec: 'worker.js', | ||
slient: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
let app = require('../app'); | ||
let debug = require('debug')('API:server'); | ||
let http = require('http'); | ||
const cluster = require('cluster'); | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
console.log(`[worker ${cluster.worker.id}] start ...`); | ||
let port = normalizePort(process.env.PORT || '3000'); | ||
app.set('port', port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
let server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port); | ||
server.on('error', onError); | ||
server.on('listening', onListening); | ||
|
||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
let port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error; | ||
} | ||
|
||
let bind = typeof port === 'string' ? | ||
'Pipe ' + port : | ||
'Port ' + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(bind + ' requires elevated privileges'); | ||
process.exit(1); | ||
break; | ||
case 'EADDRINUSE': | ||
console.error(bind + ' is already in use'); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
let addr = server.address(); | ||
let bind = typeof addr === 'string' ? | ||
'pipe ' + addr : | ||
'port ' + addr.port; | ||
debug('Listening on ' + bind); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
weibo: { | ||
CLIENT_ID: '1833831541', | ||
CLIENT_SECRET: '204239c8f3e37e59f2d3eb95de2811a9', | ||
ACCESS_TOKEN: '', | ||
MASTER_ACCESS_TOKEN: '', | ||
MASTER_COOKIES: 'SINAGLOBAL=5484186899582.633.1473772704217; _s_tentry=-; Apache=8980261524863.621.1477197913275; ULV=1477197913448:7:6:1:8980261524863.621.1477197913275:1477139933649; login_sid_t=752b624fceb9dc2cec36edd0d52acd85; UOR=,,login.sina.com.cn;SCF=Aq48LQxPt1qE63U0qWHsK8bxbvP8_cVQf74lq_fySeLLzKXgR7mwyGoBhtIa2qiADjaddlKAknPi4EuETiGbCb0.; SUB=_2A251CN2sDeTxGeNG4lEX9S3LyDqIHXVWfEhkrDV8PUNbmtBeLRHWkW8Dew228qirbEm8w5khzGUa21ZcsQ..;SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9W5WEmHY08N.cY1WYIGoLoRU5JpX5K2hUgL.Fo-R1KecSKeNe0q2dJLoIEBLxKMLB.eLBKBLxKMLB.2LBoMLxK-LBKeL1h2LxKMLB.2LBont; SUHB=0d4uo5w4_YKfuy; ALF=1508761979; SSOLoginState=1477225980; [email protected]; wvr=6', | ||
MASTER_UID: '5893653736', | ||
USER_UID: '' | ||
} | ||
} |
Oops, something went wrong.