【发布时间】:2019-01-22 16:30:07
【问题描述】:
我有一个弹性 beanstalk 上的 docker 应用程序,带有 web 服务器和工作环境。
工作环境当前通过 cron 运行计划作业。 我正在尝试将服务器连接到工作人员以实现以下目标:
- 客户端向服务器发送请求 (/trigger_job)
- 服务器通过向 SQS 队列 (/perform_job) 发送 JSON 消息将作业卸载给工作人员
- Worker 通过从 SQS 读取消息来执行工作
我无法找到有关 JSON 消息应该是什么样子的文档。提到了一些 HTTP 标头in the official documentation。但是没有提到在工作环境中指定所需端点的标头。
# server.py
from bottle import post, HTTPResponse
@post('/trigger_job')
def trigger_worker_job():
# should send a JSON message to sqs to trigger the '/perform_job'
# Need help with what the JSON message looks like
return HTTPResponse(status=200, body={'Msg': 'Sent message'})
# worker.py
from bottle import post, HTTPResponse
@post('/perform_job')
def perform_job():
# job is performed in the worker environment
return HTTPResponse(status=200, body={'Msg': 'Success'})
【问题讨论】:
-
你找到解决方案了吗?
-
天哪也卡在这里。我想知道他们是否可以将其包裹在“body”之类的东西中:等等。
标签: amazon-web-services amazon-elastic-beanstalk