Fargate: how to stop task after finishing

0

Hello. I need to calculate the PDF task on my Fargate cluster and after finishing calculating the task should be stopped or terminated to decrease payments.

The consequence of my actions:

  1. Little task always running on EC2 Cluster and check DB to the new data.
  2. If new data appears, using Boto3, run the Fargate container (big task to calculate PDF).
  3. After the job is done, the task should be stopped.

Also if in the DB appears the second row of data during proceeding the first task, Fargate should create a second task for the second job. and then stop tasks...

So, I have:

  • PDF task written on Python and deployed on ECR
  • Fargate cluster
  • Task definition (describe Memory, CPU's and container)

What is my next step? How task know, that it should be closed? Any idea or solution?

已提问 2 年前4264 查看次数
1 回答
2
已接受的回答

An ECS task (regardless of whether it's using EC2 or Fargate) exits when an essential container in the task stops or the process that gets started as part of the container entry point exits. The latter typically means that when your application stops, the task stops. Based on your description, if you are launching a new task to do the desired calculation, just have your code exit after completing the calculation.

profile pictureAWS
Mats
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则