-
Notifications
You must be signed in to change notification settings - Fork 98
Setting up last Poxa commit in Amazon EC2 running Amazon Linux AMI
Very useful EC2 guide: http://khaidoan.wikidot.com/amazon-ec2
An AMI (Amazon Machine Image) is a Operating System Image ready for using with an EC2 instance.
There are two tipes of virtualization used by the AMIs: Paravirtual (PV) & Hardware virtual machine (HVM).
Once you choose a type there is no way back: You cannot change the virtualization type of an instance or an AMI; an instance can only be resized to an instance type that supports its method of virtualization, and AMIs can only be launched on instance types that support their method of virtualization.
I recommend HVM for 2 reasons: it is said that it performs better and there are no problems on upgrading from a t2.micro to a m3.medium for example. Also AWS recommends now going for the HVM, being the only advantage of PV that PV has been much more tested (its an older type of virtualization).
You have to choose an instance and then you have to install an AMI on it. The instance is the hardware you choose and the AMI the operating system and software running on it.
For the instances we can choose t2.micro to start with the cheapest (if you have just registered in AWS you can run one t2.micro for free during a year!). Its easy to scale it in the future to bigger instances as far as we use the EBS-Backend.
There is an Amazon Linux AMI (mantained by the Amazon guys) and there are many other AMIs provided by other people / companies. Even though it could be more comfortable to start with what we now better and we use in our local machines (Ubuntu), Linux AMI is the one who is gonna better take advantage of the EC2 architecture, plus its going to be more stable and with some integrated EC2 tools in it. It is based on CentOS distribution.
With instance store volume, changes done on your EC2 instance are lost when your EC2 instance is rebooted. EBS are persistent storage volumes. Instance store volumes are non-persistent.
Amazon Linux AMI HVM EBS-Backed 64-bit (http://aws.amazon.com/amazon-linux-ami/)
Provisioned IOPS isn't included in the free layer. I can’t see a disadvantage of using the General Purpose SSD instead of the Magnetic (slower)
Storage size for root partition Its free upto 30 GB. But I don’t think we will need that much, and you can’t make them smaller (you can make them bigger), so it should be fine to go for the default 8 GB, should be enough.
You set here the protocols and Ports that you allow to access to your EC2 instance. We need:
- HTTP (port 80) allow any IP
- HTTPS (port 443) allow any IP
- SSH (port 22) ===> is how we access the instance to manage it. You should allow all IPs here, just the one from your local machine so you can access to the instance.
- Custom TCP Rule (port 8080) ===> its the default port that websockets will use to open connections. (you can change it to another port using poxa config file)
Its a .pem file that you will have to safely storage in your local machine and use each time you access your EC2 instance.
First of all download it from here: http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.63-installer.exe
Putty need a .ppk key file instead of the .pem file. So we open the PuTTY Key Generator (PuTTYgen.exe), click on Load, select "all files" and we search for the .pem file we downloaded from the AWS Console. Now we click on "save private key".
We open now PuTTY.
In the Host Name we enter ec2-user@public_DNS_of_our_instance
Port is 22
We go to Connection => SSH => Auth and we click on Browse to load the .ppk key file that we have just created in the last step.
We go to Session, choose a name (maybe Poxa EC2?) for our session in "Saved sessions" and we click on Save. Now we can clic on Open to connect with our instance.
Which versions of Erlang and Elixir do I need? ⇒ check elixir_buildpack.config from poxa repository.
(in this example requirements are Erlang 17.0 and Elixir 0.15.1)
###Installing Erlang
sudo yum install gcc glibc-devel make ncurses-devel openssl-devel autoconf
wget http://www.erlang.org/download/otp_src_17.0.tar.gz
tar zxvf otp_src_17.0.tar.gz
cd otp_src_17.0
./configure && make && sudo make install
###Installing Elixir
cd ~
wget https://github.com/elixir-lang/elixir/archive/v0.15.1.tar.gz
tar zxvf v0.15.1.tar.gz
cd elixir-0.15.1
make
cd ~
export PATH="$PATH:/home/ec2-user/elixir-0.15.1/bin"
nano .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH="$PATH:/home/ec2-user/elixir-0.15.1/bin"
export PATH
#Getting and compiling Poxa
sudo yum install git
cd ~
git clone https://github.com/edgurgel/poxa.git
cd poxa
mix deps.get
mix compile
mix compile.protocols
Now we create a file with our config for Poxa:
nano my_config.exs
use Mix.Config
config :poxa,
port: 8080,
app_key: "123456789",
app_secret: "987654321",
app_id: "yourappid"
Run Poxa:
elixir -pa _build/dev/consolidated -S mix run --config my_config.exs --no-halt