我在这个问题上被困的时间最长了:我正在将Python代码部署为一个被文档化的容器。
我在Python中完成了所有这些工作。
下面是我如何创建集群
vpc_test = _ec2.Vpc.from_lookup(self, "VPC",
vpc_id= "vpc-6****"
)
#Setting up the container to run the job
cluster = _ecs.Cluster(self, "ClusterToGetFile",
vpc=vpc_test
)
task_definition = _ecs.FargateTaskDefinition(self, "TaskDefinition",
cpu=2048,
memory_limit_mib=4096
)
task_definition.add_container("getFileTask",
image = _ecs.ContainerImage.from_asset(directory="assets", file="Dockerfile-ecs-file-download"))这是-Dockerfile-ecs-file-下载
FROM python:3.9
WORKDIR /usr/app/src
COPY marketo-ecs-get-file/get_ecs_file_marketo.py ./
COPY marketo-ecs-get-file/requirements.txt ./
COPY common_functions ./
RUN pip3 install -r requirements.txt --no-cache
CMD ["python" , "./get_ecs_file_marketo.py"]首先,我要做的就是手动运行任务(部署)。
我在get_ecs_file_marketo.py.py文件中所拥有的就是
import logging
logging.info("ECS Container has stareted. ")但是,当我部署任务时,我会得到以下错误:
Stopped reason
Essential container in task exited我的计划是使用ecs运行任务作为step函数的一部分。因此,当Lambda处理一些数据并且需要进行数据拉拔时,它将调用这个容器的RunTask。
理想情况下,我希望让Lambda的step函数来完成这一切,但是,时间限制会导致lambda在下载完整文件并推送到S3之前死亡。这将是一项常规的练习,但是,lambda前端是必需的,因为作业需要对请求进行排队,并在ecs/容器开始下载文件之前继续检查文件状态。
如有任何反馈,将不胜感激。谢谢。
发布于 2021-12-30 14:32:49
这似乎正是我所期望的那样。您的脚本所做的就是打印一条日志消息并退出。
您并没有收到真正的错误消息,您只是被通知您的脚本停止运行(因为它完成了)。
https://stackoverflow.com/questions/70532952
复制相似问题