• actionherojs 生产部署说明


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

    参考图

    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

  • 相关阅读:
    v-model
    CSS background 属性
    渐变背景
    mint ui的field用法和修改样式的方法
    js 数组包含
    password 密码查询
    web 单一平台登录逻辑
    内存共享锁业务逻辑(原创)
    无限分类树操作
    根据日期获取,x岁x月x天
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/15860947.html
Copyright © 2020-2023  润新知