How to keep the application on when ec2 get stopped? - amazon-web-services

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

Related

AWS System Manager Run Command on EC2 Failes

I'm running a fastapi server on ec2 ubuntu. Everything work fine when I ssh in to ec2 and run commands, but I want the server to be running when my local machine is off.
So, I tried AWS System manager's run command. The connection looks fine but when I cd to the server code and run ls it outputs nothing. Also, when I do poetry run python main.py in the server folder, which works totally perfect when I ssh in to the server from my local machine, it says poetry: not found.
Why is this happening. And is there another way I can run my server while being able to turn off my local machine.
There is not any kind of relation between your machine and your server in the cloud, and your ec2 its still alive and runs your services whenever you want

Running an ec2 instance from other server provider existing image

I have installed ressources on a scalway server scaleway.com (a frensh servers and cloud provider). This server uses ubuntu as os and runs a python app with many installations and configs.
In scalway, you can run a new server from a server image you had before installed or already existing. In ec2 too, you can surely launch an aws ec2 instances from an existing AMI https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html.
But, is there a way please to launch an ec2 instance with a scalway image. It will save much time in deployment of the app.
Thanks.
It seems that there is no way:
https://www.reddit.com/r/Scaleway/comments/jwha9q/is_there_a_way_to_download_an_image/

Deploying a web application for Selenium testing on AWS EC2

I have a web application that uses Selenium in backend to run few scripts when invoked by user. I want to deploy this web app on AWS.
Here are my findings so far:
I can have a windows EC2 instance created and then I can install tomcat, firefox and all the necessary stuff. Then using putty or any other client, I can deploy my war and start tomcat.
I can directly make use of Elastic Beanstalk and deploy my war file there itself but then, there is no windows EC2 available for beanstalk and I don't know how to install firefox there and make my application work.
What is the best way to achieve this and what steps should I follow. I want to install a specific firefox version to be able to make it run with my selenium scripts.
There are two separate things here:
Deployment of web application on AWS cloud
Run the selenium tests against your web application
According to me, you should first think of deploying a web application to AWS cloud. There are many ways by which you can get it deployed to AWS cloud with below services:
Spin a new AWS EC2 instance, install all required software and deploy the web application.
Use AWS elastic beanstalk service with either with tomcat or docker.
Use AWS ECS if you prefer docker
According to me, second option will be quick for you with tomcat environment option. If you select tomcat environment, then your platform will be Tomcat 8 Java 8 on 64bit Amazon Linux.
Now, here comes the second part. You can have below options for your browser environments.
Spin a new separate AWS EC2 instances with correct AMI and install your specific browsers on these instances.
If you prefer SaaS, then you can take a look at browserstack or SauceLabs for remote environment.
If you have CI(jenkins/travis/Circle CI), then make use of that infrastructure to luanch your tests with either option from the above.

Monitor application running on docker at EC2 instance

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

Created Image from running instance.Now the instance not working

I have created an image from a running instance which had a web application/service running in it.But after I did this the webservice is not working,though the running instance is fine and health checks are ok.What would have happened while I made the image?Please help
When you create an image from a running EC2 instance, it will reboot by default unless you specify the "No Reboot" option. This will have interrupted your web service, depending on how you've configured it to recover from reboots.