I have nodejs application in docker on AWS EC2 instance. It exposes port. Sometimes this application terminates and I am not able to restart it automatically. What would be the best approach on AWS EC2 in order to check and restart in case of failure?
My recommendation is to use Supervisor
Very easy to install and configure. It will start the application when the system starts up and also monitors it. If the application is not running, it will start the application.
Adding a Program
Related
what I did is I deployed Tomcat application in EC2 but I install and configure it previously before launching the ec2.
basically, when your machine of app comes up, it should have the tomcat application already deployed in it
without running the shell commands manually to install and configure tomcat.
Right now the problem is when I stopped the ec2 and start it again the tomcat application was not pop up when I hit the IP.
can you please tell me how to solve this problem?
If I understood correctly, you need to run a set of commands on instance startup to configure your application/server.
You can do this with a user data script. User data is executed at launch, and you can configure it to run on restarts as well.
If I understood right, you want your tomcat to be started everytime you restart your server.
You can configure the tomcat as a linux service and enable that service so that it will start tomcat every time your system reboots. This way, you don't have to start tomcat manually each time system reboots.
Reference: https://www.digitalocean.com/community/tutorials/install-tomcat-on-linux
I configured an AWS Fargate cluster with a docker image that runs nodejs express app and listens on port 80. Now I can browse to the public IP and successfully the request is handled by AWS Fargate.
Is it right that the docker container now is running and still waiting for requests?
Isn't it consuming CPU and so I have to pay as long as the docker container is running?
Do I have to build a docker image that just handles a single request and exits to be really serverless?
Thank you
Is it right that the docker container now is running and still waiting for requests? Isn't it consuming CPU and so I have to pay as long as the docker container is running?
Yes, that's how ECS Fargate works. It's really no different from running a docker container on your local computer. It has to be up and running all the time in order to handle requests that come in.
Do I have to build a docker image that just handles a single request and exits to be really serverless?
The term "serverless" is a vague marketing term and means different things depending on who you ask. Amazon calls ECS Fargate serverless because you don't have to manage, or even know the details of, the server that is running the container. In contrast to ECS EC2 deployments, where you have to have EC2 servers up and running ahead of time and ECS just starts the containers on those EC2 servers.
If you want something that only runs, and only charges you, when a request comes in, then you would need to reconfigure your application to run on AWS Lambda instead of ECS Fargate.
I've got a windows application that has been deployed to an AWS EC2 instance which has then been configured to run on startup via the task scheduler. This all works as intended with one exception. When I remote into the EC2 instance, I can't see the application. It's running (visible on the task manager) and producing the output as expected but the GUI is not visible and I'd like to be able to see it when I RDP into the instance.
It is being launched via the task scheduler and I can't find anything in the settings to enable the GUI to be visible for the application when I remote into the system. Is there an EC2 instance setting that needs to be enabled to make this possible?
I am setting up an infrastructure to deploy my application on AWS. I am using ECS service because I am trying to deploy a Docker-based application. So far I have created a task definition with two containers one for the apache and another one for PHP. Then I launched an ECS cluster with an EC2 instance and a task running. They all seem to be up and running. Now, I am trying to figure out how I can access the apache of my EC2 instance with the Cluster on the browser.
This is how I created the apache container.
And then I created the php container as follow.
Then I launched an EC2 based ECS cluster with one instance in it. Then I run one task within the cluster. Then I tried to open the public IP address of my instance. It just keeps loading loading and loading. What is wrong with my configuration? How can I access it on the browser?
It seems to me there's a couple of possible scenarios here you could check:
If do you reach the service and are stuck on an endless reloading loop, which might point to something in your code that could be causing it to do that,
If you're having a long wait time till the browser actually gives a timeout, which might be caused by not having the right port open on the Security Group associated with your task definition.
I'm running web service (nginx - uwsgi) on ECS.
I'm running the two applications using supervisor.
Now I want to add another service (filebeat) which will read logs of the web servers and send to logstash on another machine.
I've been told it is good idea to separate applications (all applications run on it's own docker container and get rid of supervisor)
So I'm trying to add a filebeat container to the already running webserver
If I go to define task tab of ECS menu, it seems I'm launching a new ec2 / fargate instance, that's not what I want.
Because filebeat has to run on the same host as the webserver
How do I run filebeat docker container along with webserver container?