There's a lot of ways of hosting web apps onto AWS EC2, I did it the old-fashion/barebone way where you literally SSH into the EC2 instance and run everything there.
- Download the
digitalmenu-keypair.pemfile off the Credentials folder in our team's Google Drive; this file is your login key into the AWS EC2 instance. - Move the downloaded
digitalmenu-keypair.pemfile into your SSH folder, typically located in~/.ssh - To start the SSH connection:
ssh -i ~/.ssh/digitalmenu-keypair.pem [email protected] - You should now be login as
ubuntu@ip-172-31-17-175
Once connected you can check to see if there's any running node instance via
ps -A | grep node
- If the command returns nothing, it means the backend process is not running, you can even verify this if you attempt to open up a browser and goto
ec2-34-219-160-173.us-west-2.compute.amazonaws.com:3001/restaurants/1 - Otherwise you can terminate the current node instance as shown in "Terminating the backend"
cdinto thecpen491/backendfolder- Perform
npm run start &, note the&which will allow the process to continue running even if you perform aCTRL + Cto escape the process and exit the SSH session. - You'll have to perform
CTRL + Cto escape out of the node process once, but if you perform aps -A | grep nodeagain you should see a runningnodeinstance now.
Do NOT start the cpen491/webclient, it is not configured correctly and will cause the EC2 instance to hang; requiring a forceful restart which will change the IP again (It won't be ec2-34-219-160-173.us-west-2.compute.amazonaws.com anymore)
You can get the Process ID (PID) via ps -A | grep node, once you have the PID, you can perform kill <PID> to end the process. Verify that it works by doing ps -A | grep node.
You can gracefully exit out of the SSH session via the command exit
You can upload files via scp
In this example, we're copying a folder name data on our local machine and its content (hence -r for recursive) onto the instance in the same folder name on the EC2 instance.
scp -i ~/.ssh/digitalmenu-keypair.pem -r ~/data [email protected]:~/data