mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-02-01 15:23:03 +00:00
capture error in app start
This commit is contained in:
parent
8079f37924
commit
51b8b348c5
@ -172,7 +172,8 @@ export default class extends think.base {
|
||||
//create server
|
||||
let server = http.createServer(callback);
|
||||
if (think.config('websocket.on')) {
|
||||
(new websocket(server, this)).run();
|
||||
let instance = new websocket(server, this);
|
||||
instance.run();
|
||||
}
|
||||
server.listen(port, host);
|
||||
this.logPid(port);
|
||||
|
||||
13
src/index.js
13
src/index.js
@ -374,6 +374,16 @@ export default class {
|
||||
}, 1000);
|
||||
thinkCache(thinkCache.TIMER, 'auto_reload', timer);
|
||||
}
|
||||
/**
|
||||
* capture error
|
||||
* @return {} []
|
||||
*/
|
||||
captureError(){
|
||||
process.on('uncaughtException', function(err){
|
||||
err = think.error(err, 'port:' + think.config('port'));
|
||||
think.log(err);
|
||||
})
|
||||
}
|
||||
/**
|
||||
* start
|
||||
* @return {} []
|
||||
@ -381,6 +391,7 @@ export default class {
|
||||
start(){
|
||||
this.checkEnv();
|
||||
this.load();
|
||||
this.captureError();
|
||||
if (think.config('auto_reload')) {
|
||||
this.autoReload();
|
||||
}
|
||||
@ -390,8 +401,8 @@ export default class {
|
||||
* @return {} []
|
||||
*/
|
||||
async run(){
|
||||
this.start();
|
||||
try{
|
||||
this.start();
|
||||
await think.require('app').run();
|
||||
}catch(err){
|
||||
think.log(err);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user