diff --git a/docs/source/en/basics/config.md b/docs/source/en/basics/config.md index 9ca6577956..69305cb41b 100644 --- a/docs/source/en/basics/config.md +++ b/docs/source/en/basics/config.md @@ -73,6 +73,18 @@ root | The application root directory, if the environment is local or unit `appInfo.root` is an elegant adaption. for example, we tend to use ``/home/admin/logs`` as the catalog of log in the server environment, while we don't want to pollute the user catalog in local development. This adaptation is very good at solving this problem. +Choose the appropriate style according to the specific situation, but please make sure you don't make mistake like the code below: + +```js +// config/config.default.js +exports.someKeys = 'abc'; +module.exports = appInfo => { + const config = {}; + config.keys = '123456'; + return config; +}; +``` + ### Sequence of loading configurations Applications, plugin components and framework are able to define those configs. Even though the structure of catalog is identical but there is priority (application > framework > plugin). Besides, the running environment has the higher priority. diff --git a/docs/source/en/faq.md b/docs/source/en/faq.md index 8d62c17fb2..bdb268876a 100644 --- a/docs/source/en/faq.md +++ b/docs/source/en/faq.md @@ -21,6 +21,18 @@ Framework [Config](./basics/config.md) settings is powerfull, support different When you got some trouble, and want to find out what is the final config using at runtime, you can checkout `${root}/run/application_config.json`(workers' configurations) and `${root}/run/agent_config.json`(agent's configurations).(`root` is application's root directory, in `local` and `unittest` environments, it will be project base directory, in other environments will be HOME directory) +Please make sure you don't make mistake like the code below: + +```js +// config/config.default.js +exports.someKeys = 'abc'; +module.exports = appInfo => { + const config = {}; + config.keys = '123456'; + return config; +}; +``` + ## Where are my log files in prod environment? By default, logs will print at `${baseDir}/logs`(baseDir is project's base directory) in local environment.But in non-development environments(neither local nor unittest), the logs will print at `$HOME/logs`(such as `/home/admin/logs`). So the logs won't mix in during development and locate in the same place when run in production environment. diff --git a/docs/source/zh-cn/basics/config.md b/docs/source/zh-cn/basics/config.md index d1ccd13372..5f66b746d9 100644 --- a/docs/source/zh-cn/basics/config.md +++ b/docs/source/zh-cn/basics/config.md @@ -76,6 +76,19 @@ root | 应用根目录,只有在 local 和 unittest 环境下为 baseDir,其 `appInfo.root` 是一个优雅的适配,比如在服务器环境我们会使用 `/home/admin/logs` 作为日志目录,而本地开发时又不想污染用户目录,这样的适配就很好解决这个问题。 + +请根据具体场合选择合适的写法,但请确保没有写出以下代码: + +```js +// config/config.default.js +exports.someKeys = 'abc'; +module.exports = appInfo => { + const config = {}; + config.keys = '123456'; + return config; +}; +``` + ### 配置加载顺序 应用、插件、框架都可以定义这些配置,而且目录结构都是一致的,但存在优先级(应用 > 框架 > 插件),相对于此运行环境的优先级会更高。 diff --git a/docs/source/zh-cn/faq.md b/docs/source/zh-cn/faq.md index 52749de58c..e28338bf9a 100644 --- a/docs/source/zh-cn/faq.md +++ b/docs/source/zh-cn/faq.md @@ -23,6 +23,18 @@ title: 常见问题 也可参见[配置文件](https://eggjs.org/zh-cn/basics/config.html#配置结果)。 +PS:请确保没有写出以下代码: + +```js +// config/config.default.js +exports.someKeys = 'abc'; +module.exports = appInfo => { + const config = {}; + config.keys = '123456'; + return config; +}; +``` + ## 线上的日志打印去哪里了? 默认配置下,本地开发环境的日志都会打印在应用根目录的 `logs` 文件夹下(`${baseDir}/logs`) ,但是在非开发期的环境(非 local 和 unittest 环境),所有的日志都会打印到 `$HOME/logs` 文件夹下(例如 `/home/admin/logs`)。这样可以让本地开发时应用日志互不影响,服务器运行时又有统一的日志输出目录。