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

自定义环境配置未加载 #3312

Closed
dsky1990 opened this issue Dec 14, 2018 · 3 comments
Closed

自定义环境配置未加载 #3312

dsky1990 opened this issue Dec 14, 2018 · 3 comments

Comments

@dsky1990
Copy link

node环境 :8.12.0

自定义了一个EGG_SERVER_ENV=site

npm 运行命令"testEnv": "ENABLE_NODE_LOG=YES NODE_LOG_DIR=/tmp/ EGG_SERVER_ENV=sit NODE_ENV=production egg-scripts start --daemon --title=egg-server-dubbo-egg",

image
也增加了一个配置文件,配置如下

'use strict';
const path = require('path');
const  fs = require('fs');
module.exports = appInfo => {
  const config = exports = {};
  // 获取路径下文件列表
  function findSync(startPath) {
    let result=[];
    function finder(path) {
      const files=fs.readdirSync(path);
      files.forEach((val,index) => {
        if (val.indexOf('.js')>=0) {
          result.push(val.replace('.js', ''))  
        }
      });
    }
    finder(startPath);
    return result;
  }
  const baseDir = appInfo.baseDir;
  let controllerArray=findSync(path.join(process.cwd(), 'app/controller')); // 获取controller文件夹下面的文件列表
  const errArray = [
    path.join(baseDir, 'logs/dubbo-egg/common-error.log'),
    path.join(baseDir, 'logs/dubbo-egg/dubbo-bff-web.log'),
    path.join(baseDir, 'logs/dubbo-egg/egg-agent.log'),
    path.join(baseDir, 'logs/dubbo-egg/egg-web.log')
  ]
  controllerArray.forEach(val=> {
    errArray.push(path.join(baseDir, `logs/dubbo-egg/${val}/error.log`))
  })
  config.alinode = {
    enable: true,
    server: 'wss://agentserver.node.aliyun.com:8080',
    appid: '',
    secret: '',
    error_log: errArray,
    packages: [
        path.join(baseDir, './package.json'),
    ],
  };
  return config;
};

local环境alinode可以被加载到,但是sit环境下不行,感觉是配置未加载

@atian25
Copy link
Member

atian25 commented Dec 14, 2018

看下 run 目录下的 application_config.json 里面,对应的 plugin 和 config 节点是否合并正确吧。

PS: egg-scripts start --env=sit --daemon --title=egg-server-dubbo-egg 即可,那些 env 没必要。

@egg-bot
Copy link

egg-bot commented Dec 14, 2018

Hello @dsky1990. Please provide a reproducible example following the instruction.

Issues labeled by Need Reproduce will be closed if no activities in 7 days.


@dsky1990,请根据这个说明提供最小可复现代码。

如果在 7 天内没有进展会被自动关闭。

@dsky1990
Copy link
Author

@atian25 刚看了一眼,现在有了- -很奇怪,感谢帮助

@atian25 atian25 closed this as completed Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants