forked from OneBusAway/onebusaway-application-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Cloud Deployment
sheldonabrown edited this page May 7, 2014
·
2 revisions
The cloud deployment is via Amazon Web Services.
It is a mix of Cloudformation and Chef configuration.
The Cloudformation is here: https://github.com/camsys/hart/tree/master/cloudformation
The Chef repository is here: https://github.com/camsys/hart/tree/master/chef-repo
- checkout Tampa codebase:
$ git clone [email protected]:Hillsborough-Transit-Authority/onebusaway-application-modules.git onebusaway-hart
- verify localizations are intact (route suggestion, etc)
- build
$ cd onebusaway-hart && mvn clean install
- spin up an ec2 instance from the existing AMI
- deploy
$ scp onebusaway-combined-webapp/target/onebusaway-combined-webapp-X.Y.Z-SNAPSHOT-full.war [email protected]:/tmp/ROOT.war
$ ssh [email protected]
$ cd /var/lib/tomcat6/webapps
$ sudo service tomcat6 stop
$ sudo rm -rf ROOT.war
$ sudo mv ROOT old
$ sudo mv /tmp/ROOT.war ./
$ sudo mkdir ROOT
$ cd ROOT
$ sudo jar xvf ../ROOT.war
// we comment out phone/IVR support
$ sudo cp ../old/WEB-INF/web.xml WEB-INF
// we provide db and other setup info
$ sudo cp ../old/WEB-INF/classes/data-sources.xml WEB-INF/classes
// we need to manually add the mysql driver
$ sudo cp ../old/WEB-INF/lib/mysql* WEB-INF/lib
$ sudo rm -rf ../old
$ sudo service tomcat6 start
```
* verify the app starts up
```
$ tail -f /var/log/tomcat6/catalina.out
```
* create an image/AMI from this instance
* update the AMI reference in cfn-app-elb.json
* update the cloudformation stack with the new AMI
* increase the desired instance count to roll in the new AMI
## Workflow - chef-solo
* spin up a new ec2 instance from the latest ubuntu cloud version http://cloud-images.ubuntu.com/server/precise/current/
* execute chef-solo
```
$ apt-get update
$ apt-get install -y ruby1.9.1-full build-essential wget git emacs23-nox
$ gem update --no-rdoc --no-ri
$ gem install ohai chef --no-rdoc --no-ri
$ git clone https://github.com/camsys/hart.git
$ chef-solo -j /home/ubuntu/hart/chef-repo/roles/oba-webapp.rb -c /home/ubuntu/hart/chef-repo/solo.rb -E obahart_prod
```
* create an image/AMI from this instance
* update the AMI reference in cfn-app-elb.json
* update the cloudformation stack with the new AMI
* increase the desired instance count to roll in the new AMI
## Gotchas
* During the initial rollout, the /api/api was redirected to /api via mod_rewrite which caused some issues. At issue was this:
```
RewriteRule ^/api/api(.+) /api$1 [R,T]
```
The above redirect re-encoded some of the URL parameters breaking them for the android. Its not clear if this is an improper encoding issue with the adroid or a fault of apache encoding. The fix is this:
```
RewriteRUle ^/api/api(.+) /api$ [PT]
```
The "P" flag tells apache to proxy internal instead of redirecting.