javascript - 在 Amazon Elastic Beanstalkd 上部署 Javascript Cron 作业和队列
问题描述
我有一个Amazon Elastic Beanstalk应用程序,目前正在运行我的NODE.JS应用程序。
我用kue.js创建了一些队列,用node-schedule创建了 Crons 。
由于我有许多命令来运行队列和 cron,我发现无法将它放在我当前的 nodejs 应用程序上。
我愿意打开一个新的应用程序,唯一的问题是我只能运行一个命令。
我真的不想打开一个单独的 ec2(未连接到我的 Elastic Beanstalk 服务)来运行所有这些。
我能做些什么来修复它?
非常感谢!
解决方案
当您想使用 EB(Elastic Beanstalk)时,您可以为应用程序编写一个 docker 文件,EB 已经检测到它并询问您这是否是一个基于 docker 的项目,它会处理其余的,您只需要编写所有您需要在入口点命令 CMD 之前运行的脚本,npm start
如下所示
Dockerfile
FROM node:10.13-alpine
# Sets the working directory,and creates the directory as well.
WORKDIR /app
# Install dependencies.
ADD package.json .
RUN npm install
# Copy your source code.
COPY . /app
#Run all your scripts here or simply put them to a scripts.js and run it
RUN node scripts.js
# start app
CMD ["npm", "start"]
推荐阅读
- python - 如何编写迭代整个数据集的批处理生成器
- css - 使用不同的样式表会提高网站的性能吗?
- docker - 如何为所有 pod 创建和挂载公共数据
- docker - 如何在 Pod 间广播 gRPC 流
- node.js - 如何在网站 json api 中获取第一个 json 文件?
- javascript - 发出请求时 GCF 超时
- pyqt5 - 如何在关闭所述弹出窗口的弹出窗口内制作一个按钮?
- android - 尝试单击单选按钮时如何解决 Robo 测试失败?
- python - Python iloc给出indexError:单个位置索引器在简单的for循环中超出范围
- java - 通过具有字符限制的 JOptionPane 输入字符串