Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(faq): add the most common mistake of config #2086

Merged
merged 3 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/source/en/basics/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions docs/source/en/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions docs/source/zh-cn/basics/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
```

### 配置加载顺序

应用、插件、框架都可以定义这些配置,而且目录结构都是一致的,但存在优先级(应用 > 框架 > 插件),相对于此运行环境的优先级会更高。
Expand Down
12 changes: 12 additions & 0 deletions docs/source/zh-cn/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)。这样可以让本地开发时应用日志互不影响,服务器运行时又有统一的日志输出目录。
Expand Down