actionherojs 支持集群以及ha 模式,同时支持web 与worker分离

参考图

actionherojs 生产部署说明

 

 

woker&web分离配置

/ Assume we use the flag \`process.env.ACTIONHERO_ROLE\` to denote the type of server
// You can set this variable in the ENV of your server or launch each process with the flag:
// Worker => \`ACTIONHERO_ROLE='worker' npm start\`
// Server => \`ACTIONHERO_ROLE='server' npm start\`
 
// config/tasks.ts
 
exports.production = {
  tasks: function () {
    // default to config for 'server'
    let config = {
      scheduler: false,
      queues: ["*"],
      verbose: true,
      // ...
    };
 
    if (process.env.ACTIONHERO_ROLE === "worker") {
      config.scheduler = true;
      config.minTaskProcessors = 1;
      config.maxTaskProcessors = 10;
    }
 
    return config;
  },
};
 
// config/web.ts
 
exports.default = {
  web: function () {
    config = {
      enabled: true,
      secure: false,
      serverOptions: {},
      port: process.env.PORT || 8080,
      // ...
    };
 
    if (process.env.ACTIONHERO_ROLE === "worker") {
      config.enabled = false;
    }
 
    return config;
  },
};

说明

官方文档是比较值得阅读的,里边包含了好多生产环境的最佳实践

参考资料

https://www.actionherojs.com/tutorials/production-notes

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-11-18
  • 2021-05-12
  • 2021-10-26
  • 2021-12-19
猜你喜欢
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
相关资源
相似解决方案