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년 전4262회 조회
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠