ctripcorp / cat.js Goto Github PK
View Code? Open in Web Editor NEWJavascript client of CAT
License: Apache License 2.0
Javascript client of CAT
License: Apache License 2.0
Hi,在部署 node.js 应用时发现,如果不在 node.js 项目文件夹里面启动,而是在外层文件夹启动 node.js 应用,将会找不到 app.config.js
文件。
错误日志:[AppConfig] No avaliable app.config.js found in /opt/tars/apps/100004256
具体原因是因为, app.config.js
的查询方式为
var appConfig={};
var lastConfigDir='';
var dirname=path.resolve(".");
while (dirname!==lastConfigDir){
try {
var config=path.resolve(dirname,'./app.config.js');
appConfig=require(config);
if (!appConfigHidden){
console.log('[AppConfig] Load config from '+config);
}
break;
}catch (e){
if (!appConfigHidden){
console.log('[AppConfig] No avaliable app.config.js found in '+dirname);
}
lastConfigDir=dirname;
dirname=path.dirname(lastConfigDir);
}
}
其中,var dirname=path.resolve(".");
默认以 process.cwd()
node.js 的启动目录为基准,一层层往外找父目录。
如果改成 var dirname= __dirname;
,将以 appConfig.js 文件所在的目录往上找,通常该文件在 node_modules
文件夹 里,所以应该会在 node.js 项目的文件夹内,此时不管 process.cwd()
指向哪个目录,都不会影响 app.config.js
的查找方式。
createError Function内,当err类型为object时,会调用未定义函数getType。进程会因此挂掉,麻烦修复,谢谢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.