feature: support preload packages before start server

This commit is contained in:
lichengyin 2016-01-22 12:52:18 +08:00
parent a549ee4f7e
commit 85d39fa007
2 changed files with 16 additions and 2 deletions

View File

@ -13,7 +13,7 @@ export default {
app: `${rootPath}core${sep}app.js`,
http: `${rootPath}core${sep}http.js`,
view: `${rootPath}core${sep}view.js`,
auth: `${rootPath}util${sep}auth.js`,
// auth: `${rootPath}util${sep}auth.js`,
cookie: `${rootPath}util${sep}cookie.js`,
validator: `${rootPath}util${sep}validator.js`,
await: `${rootPath}util${sep}await.js`,

View File

@ -432,12 +432,26 @@ export default class {
think.autoCompile = true;
}
/**
* pre require
* @return {} []
*/
preload(){
let startTime = Date.now();
for(let name in thinkData.alias){
think.require(thinkData.alias[name]);
}
think.log('preload packages finished', 'PRELOAD', startTime);
}
/**
* run
* @return {} []
*/
run(){
run(preload){
this.start();
if(preload){
this.preload();
}
return think.require('app').run();
}
/**