Swift is intended to be used in rapidly evolving crisis situations such as a tsunami or a civic disaster. Over the last year as the Swift app has been being developed there have been a number of events that fit the profile. The Mumbai terrorist incident is a good example. Each crisis has helped us improve the engine, hopefully soon it will be able to provide real value to help out in crisis situations. In this post we review how to build an instance of Swift.
Deploying Swift quickly and easily however is a hassle. Chris Blow decided that we should build an EC2 instance that anybody could clone. The hope is that this will help speed crisis intervention and help provide better information to first responders in the field more quickly.
This post is technical, we were just focused on how to build a clean version of Swift. Here’s the set of incantations that we went through to do this. After this there will be a packaging and cloning step, and of course running Swift agents to keep watching crowd-sourced traffic. Swift itself is continuing to evolve of course.
Here’s the incantation if you want to do this from scratch:
# Spawn an EC2 Instance
# created the instances based on the jaunty jackalpe AMI by Eric Hammond
# Fix the EC2 instance to allow remote ssh logins so that your friends can help you
sudo vi /etc/ssh/sshd
PasswordAuthentication yes
restart the sshd
sudo kill -HUP 1080
# Add your friends to sudoers so then can actually do useful stuff
sudo vi /etc/sudoers
so it looks like this or thereabouts:
# User privilege specification
root ALL=(ALL) ALL
anselm ALL=(ALL) ALL
chris ALL=(ALL) ALL
# Go ahead and make sure that apt is updated and the like
# https://help.ubuntu.com/8.04/serverguide/C/apt-get.html
# We’re going to battle our way through installing rails
# We want a TON of core ubuntu packages that are totally unrelated to rails as well
# http://www.hackido.com/2009/04/install-ruby-rails-on-ubuntu-904-jaunty.html
# mysql will ask for a password – i just set it to the word ‘password’
apt-get update
apt-get dist-upgrade
apt-get install build-essential
apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 libhtml-template-perl mysql-server-core-5.0
apt-get install subversion git git-core
apt-get install apache2 apache2-prefork-dev libapr1-dev libaprutil1-dev
apt-get install libxml2 libxml2-dev libxslt libxslt-dev
# install ruby gems…
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar zxvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem
ln -s /usr/bin/ruby1.8 /usr/bin/ruby
ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc
ln -s /usr/bin/ri1.8 /usr/bin/ri
ln -s /usr/bin/irb1.8 /usr/bin/irb
gem install rails –no-rdoc –no-ri
gem install passenger
passenger-install-apache2-module
# let’s not bother installing passenger-install-ningx-module
# on ubuntu apache2 and ningx and the like seem to like to put the websites in /var/www
# lets fetch the swift app and put it there
cd /var/www
git clone git://github.com/unthinkingly/swiftriver.git
# and lets make the db… it is mysql for now … later hopefully postgresql or builtin
cd swiftriver
cp config/database.yml.sample config/database.yml
mysql -p # when i installed mysql i set the password to ‘password’ so use that when it asks
mysql> create database swift;
mysql> flush privileges;
mysql> exit;
# now the database is up – this is needed to do the rake step below
# now lets configure the app by letting it pull in a million billion gems and the like
gem sources -a http://gems.github.com
gem install mongrel fastthread json GeoRuby haml mislav-will_paginate daemons
gem install ruby-debug
gem install gchart
rake gems:install
vi config/environment.rb # > correct the dependency versions such as for haml to be the same as system!
# let us try migrate the actual database in!!!
rake db:migrate
# lets run tests
rake test
# Finally you can even RUN IT! LOOK AT IT! HAVE AWE!
script/server start
apt-get install lynx
lynx http://localhost:3008
# I guess you can add passenger phusion too
# http://www.modrails.com/documentation/Users%20guide%20Apache.html
vi /etc/apache2/sites/default
I added this:
Listen *:80
NameVirtualHosts *:80
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
PassengerRuby /usr/bin/ruby
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5
PassengerMaxPoolSize 10
<VirtualHost *:80>
ServerName swift.org
DocumentRoot /var/www/swiftriver/public
RailsBaseURI /rails
RailsEnv development
</VirtualHost>
# notice my magic about about being in development mode in rails for passenger …
# to restart this under apache you can restart apache or magically kick passenger to restart itself:
/etc/init.d/apache2 stop
/etc/init.d/apache2 start
cd /var/www/swiftriver
mkdir tmp
touch tmp/restart.txt
# also there is some detail with mysql performance that may be worth looking at see:
# http://www.hackido.com/2009/04/install-ruby-rails-on-ubuntu-904-jaunty.html
One Comment
borrrrrrrrring!