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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ