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?

posta 2 anni fa4261 visualizzazioni
1 Risposta
2
Risposta accettata

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
con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande