DEV Community

Discussion on: Deploy Rails in Amazon ECS: Part 4 - Create an ECS Cluster

 
raphael_jambalos profile image
Raphael Jambalos • Edited

Hi Nico,

From your reply, it seems to me that the your app fails the health check. I recommend the following:

(i) I think your application has some configuration problems that you might need to address. For this approach, we would look at your application logs.

Go to yourcluster > yourservice, and go to the "Tasks" tab. Inside the tab, find "Task Status:" and then click "Stopped". You will see a list of tasks that have been stopped. Click one of those tasks. You will be redirected to a page with information about your task. Try playing around with this page. You will see a reason why the task was killed. If you don't find anything useful, go to the "logs" tab. You will see application logs from that specific task (assuming you did step 7.6-7.7 perfectly ).

Alt Text

(ii) If your app is perfectly normal, then I think the load balancer is killing your app even before it has the chance to turn on. For this approach, we would add a grace period.

Go to your service and find the option for the Health Check grace period. If it's zero, turn it to 300s. If it's more than zero, double it.

Alt Text

Kindly let me know if this helps!

Thread Thread
 
nicobuchhalter profile image
NicoBuchhalter

Hi Raphael! Thank you again for the help.

So, yes, clearly the tasks are being stopped but I can't understand the reason why. The logs don't give me any information. The only message I see in the task is "Essential container in task exited" and in the logs "Switch to inspect mode".
I tried to deploy a previous version of the app, to make sure it was stable, and still didn't create the image.
I changed the grace period and the image still didn't appear in the EC2 instance.

I think everything points to my app itslef malfuctioning, but locally I can run the image just fine and same with docker-compose.

I don't want to spam so much this thread so if you prefer, we can chat directly. Thank you a lot!

Thread Thread
 
raphael_jambalos profile image
Raphael Jambalos

Hi Nico,

Sorry for the delayed reply. It's been a long week at work. I think what you have to do is SSH to the EC2 instance directly. Then, do docker ps and find the container. If it's not there, do docker ps -a to see containers who recently died. Try to do docker log <chash> first.

Then, try to revive the container via docker start <chash>, and then you'd be able to go inside the container via docker exec -it <chash>. Then, explore your app. Look for log files that may contain clues to why your app failed.

If you prefer, you can also send screenshots of your task to me (via PM). [mycluster > myservice > tasks > click on one of the tasks].