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;
},
};
说明
官方文档是比较值得阅读的,里边包含了好多生产环境的最佳实践
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2021-02-02 cube.js playground暴露的几个不错的功能
2021-02-02 cube.js 生产集成使用的几点说明
2021-02-02 cube.js 上线文 filter 处理的原理
2020-02-02 golang 条件编译
2019-02-02 cget cmake 包管理工具
2019-02-02 buckaroo 试用
2019-02-02 buckaroo 去中心化的c++包管理工具