我正在开发一个文件处理系统,可以将文件上传到S3,然后在容器中进行处理。我一直在使用触发ECS从lambda运行任务并传递一些环境变量。
S3 -> Lambda -> ECS
我遇到了一个问题,我似乎不能一次跑超过一个任务。如果一个任务已经在运行,那么任何后续运行的任务都会被困在“供应”中,并最终完全消失。
下面是运行ECS任务的lambda函数:
const params: RunTaskRequest = {
launchType: "FARGATE",
cluster: "arn:aws:ecs:us-east-1:XXXXXXX:cluster/FileProcessingCluster",
taskDefinition: "XXX",
networkConfiguration: {
awsvpcConfiguration: {
subnets: [
"subnet-XXX",
"subnet-XXX"
],
securityGroups: [
"..."
],
assignPublicIp: "DISABLED"
}
},
overrides: {
containerOverrides: [
{
name: "FileProcessingContainer",
environment: [
...
]
},
]
},
};
try {
await ecs.runTask(params).promise();
}catch (e) {
console.error(e, e.stack)
}我使用AWS创建ECS基础设施:
const cluster = new ecs.Cluster(this, 'FileProcessingCluster', {
clusterName: "FileProcessingCluster"
});
const taskDefinition = new ecs.FargateTaskDefinition(this, "FileProcessingTask", {
memoryLimitMiB: 8192,
cpu: 4096,
});
taskDefinition.addContainer("FileProcessingContainer", {
image: ecs.ContainerImage.fromAsset("../local-image"),
logging: new ecs.AwsLogDriver({
streamPrefix: `${id}`
}),
memoryLimitMiB: 8192,
cpu: 4096,
});这里有什么东西我遗漏了吗?也许是与并发任务相关的设置?
发布于 2020-11-16 19:12:51
https://stackoverflow.com/questions/64858612
复制相似问题