From 6506357199da4eba4588efd54bbecc29eeeec853 Mon Sep 17 00:00:00 2001 From: Joseph Snow Date: Sat, 19 Nov 2011 21:50:39 -0700 Subject: [PATCH] added boot script notes. updated boot/start scripts with latest push attempt --- util/boot.sh | 56 +++++++++++++++++++++++++++++++++------- util/crontab-example.txt | 1 + util/start.sh | 2 +- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/util/boot.sh b/util/boot.sh index bf51f79..65ebb68 100755 --- a/util/boot.sh +++ b/util/boot.sh @@ -1,5 +1,28 @@ #!/bin/bash + +################################################################ +## Finals Club instance set up notes by Joe Snow 11/19/2011 +################################################################ +## these are the steps I take to create a new fc instance +## log into aws, launch new AMI instance +## ssh into machine +## sudo to root +## download and run boot.sh (this file -- either from s3 or ssh), this can take 10 minutes +## NOTE: start.sh usually fails due to env vars, etc.. +## as ec2-user, run start.sh +## add arbiter db config, and mongo replicated set config, import mongo data using mongorestore command +## I usually create and grab the latest mongodb backup from S3 (created from existing live server) +## add dev public keys to /home/ec2-user/.ssh/authorized_keys +## update /home/ec2-user/.bashrc with AWS env vars +## add /home/ec2-user/fc/fcbackup/.fcbackup.env (populated with AWS env vars) +## restart fc app +## add crontab, using fc/util/crontab-example.txt as example as needed. +## update cloudwatch monitors for cpu, disk, etc.. +## as root, start epl monitor script in /home/ec2-user/fc/util/start-fc-epl-monitor.sh +## check app health and switch DNS as desired +################################################################ + cd /root if test ! -e "reset.sh" ; then @@ -38,26 +61,37 @@ if test ! -e mongodb.tgz ; then ## optional arbiter start command ## mkdir -p /data/arbiterdb ## /usr/local/bin/mongod -v --dbpath /data/arbiterdb --port 27021 --rest --replSet finalsclubset &> /var/log/mongod-arbiter.log & + + #### NOTE: the replicated set name could change or increment, for example we might be using finalsclubset4 instead of finalsclubset + + ## example to set up new clean replicated set + ## as ec2-user + ## mongo ### start mongo cli util from bash prompt + ## > rs.initiate() ## init the replicated set (assumes you are starting a new clean replicated set) + ## > rs.addArb("ip-10-166-206-34:27021") ## assumes arbiter instance was started previously on specified port, IP for example only, use same machineID + ## > rs.status() ## confirm both instances are in set fi + + # install node nodever="v0.4.10" if test ! -e node-$nodever ; then - curl http://nodejs.org/dist/node-$nodever.tar.gz > node-$nodever.tar.gz - tar xzvf node-$nodever.tar.gz - cd node-$nodever - ./configure - make - make install + curl http://nodejs.org/dist/node-$nodever.tar.gz > node-$nodever.tar.gz + tar xzvf node-$nodever.tar.gz + cd node-$nodever + ./configure + make + make install fi # install npm if test ! -e npm ; then - git clone http://github.com/isaacs/npm.git - cd npm - sudo make install - cd .. + git clone http://github.com/isaacs/npm.git + cd npm + sudo make install + cd .. fi npm install nodemon -g @@ -92,5 +126,7 @@ chmod 755 reboot-restart.sh echo "/root/reboot-restart.sh &> /var/log/fc-reboot-restart.log.txt &" >> /etc/rc.local +## NOTE: each time, I've had to run this step manually, as the ec2-user, after env vars have been set up +cd /home/ec2-user curl https://s3.amazonaws.com/finalsclub.org/start.sh | sudo -u ec2-user sh diff --git a/util/crontab-example.txt b/util/crontab-example.txt index f0b87f9..d702e8c 100644 --- a/util/crontab-example.txt +++ b/util/crontab-example.txt @@ -10,6 +10,7 @@ ## added by jsnow on 11/9/2011 ## this script checks if EPL is up and running. if not, it sends an alert email +#### this cron task is disabled, we're using fc/util/start-fc-epl-monitor.sh instead #### 5,20,35,50 * * * * /home/ec2-user/fc/util/fc_monitor_epl_cron.sh > /home/ec2-user/fc/util/fc_monitor_epl_cron.log.txt ## added by jsnow on 11/10/2011 diff --git a/util/start.sh b/util/start.sh index ed3d5f3..b778906 100755 --- a/util/start.sh +++ b/util/start.sh @@ -12,7 +12,7 @@ npm install express-messages npm install jade cd ~ -rm -rf fc +rm -rf FinalsClub git clone git@github.com:finalsclubdev/FinalsClub.git ln -sf FinalsClub fc -- 2.25.1