uh what is pm2?
(and a bonus guide on how AMI/Templates)
a persontaton by danny wong
slightly updated bc SDC is over and we kinda don’t need the last half of this presentation (still included in case anyone wanted to reference it !)
Some cool features
If we had better instances, we could also leverage multiple CPU cores to load balance for us with PM2’s cluster mode (but t.2 micro is sad and only has 1 CPU core)
Very simple install
pm2 show (process number)
shows some useful information about that selected process
you can also use pm2 monit to bring up this cool CLI that shows you all the apps you have running and monitor each of their logs
Now how can we use this for SDC????
So how do we accomplish that last point from that last slide you may ask??
So in order to have PM2 startup when the EC2 instance starts(boots up)(whatever), we need to do the following
The following slide will be what it looks like after you run that command
Here’s that pretty cool thing I mentioned earlier
So if we want to create more EC2 instances to add to our load balancer, we wouldn’t want to manually go and set up the servers every time right?
Here’s a mini tutorial on how to create an image from an existing EC2 instance
(basically copy pasting your entire base EC2 instance)
Now we can use this in conjunction with Launch Templates
Hit that button
Congrats! You’ve now created a carbon copy of your first instance
No need to set up node/npm or do git clone to set up the server
The even cooler thing now, is that because we set up pm2 to auto start our node app AND set up pm2 to start up as a service when the instance first boots, there’s no need to SSH into the instance AT ALL to get anything set up! (asterisk)
You can simply grab the URL from your AWS portal and add it to your nginx loadbalance config file! (make sure to include the port if you didn’t do port-forwarding!! )
asterisk: this is assuming you set everything up you may have needed already.
i.e.
It will name it the same name as your template instance so make sure to change it later so you can easily identify your new instances