How to regularly clean up hung Fargate tasks

0

I have identical ECS clusters spread across several AWS regions. They are configured to run a short running fargate task on demand. Sometimes these tasks do not complete; they "hang" in the running state.

I'm going to figure out why that happens separately, what I'd like to do as a stopgap is to regularly purge tasks that have been running for longer than an hour for example.

It looks like I can do this with systems manager; run a script that goes and gets all running tasks from the cluster in each region, then stop those that have been running for too long. Will this work, and is there a better way to do this?

gefragt vor 2 Jahren203 Aufrufe
1 Antwort
1
Akzeptierte Antwort

Sure, it's possible to have an external process like an SSM document or a lambda that finds and kills them. But I would probably only use the timeout util in the startup command when you start your app. https://linuxize.com/post/timeout-command-in-linux/

the command would look something like this: timeout 3600 start service.

Hope it helps!

profile picture
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen