Permalink
Browse files

Merge branch 'dev'

  • Loading branch information...
2 parents afc40b3 + f1183a0 commit c6e6f067dfdfe11ef7ddefe573ffd86720057d82 @andyl committed Jun 13, 2012
Showing with 18,129 additions and 416 deletions.
  1. +0 −1 .env
  2. +1 −0 .gitignore
  3. +1 −1 .idea/.rakeTasks
  4. +3 −0 .idea/BAMRU-Private.iml
  5. +17,455 −3 .idea/dataSources.ids
  6. +1 −1 .idea/dataSources.xml
  7. +11 −0 .rbenv-vars
  8. +1 −1 .vagrant
  9. +20 −18 Capfile
  10. +4 −0 Gemfile
  11. +12 −0 Gemfile.lock
  12. +1 −0 Procfile
  13. +1 −0 Procfile.dev
  14. +77 −18 README.md
  15. +42 −36 app/controllers/api/rake/messages_controller.rb
  16. +1 −0 app/controllers/api/rake/password_controller.rb
  17. +3 −0 app/controllers/api/rake/reminders_controller.rb
  18. +1 −1 app/controllers/messages_controller.rb
  19. +0 −1 app/models/outbound_mail.rb
  20. +86 −0 app/models/qc_mail.rb
  21. +16 −0 app/models/qc_show.rb
  22. +9 −1 config/database.yml
  23. +14 −0 config/deploy/devstage.rb
  24. +6 −8 config/deploy/production.rb
  25. +12 −0 config/deploy/pubstage.rb
  26. +2 −1 config/deploy/shared/base/base.rb
  27. +50 −0 config/deploy/shared/base/data.rb
  28. +21 −0 config/deploy/shared/base/railsenv.rb
  29. +15 −0 config/deploy/shared/packages/cron.rb
  30. +1 −1 config/deploy/shared/packages/foreman.rb
  31. +25 −0 config/deploy/shared/packages/monit.rb
  32. +0 −9 config/deploy/shared/packages/nodejs.rb
  33. +8 −0 config/deploy/shared/packages/templates/monit_alert.erb
  34. +8 −0 config/deploy/shared/recipes/console.rb
  35. +0 −29 config/deploy/shared/recipes/depext.rb
  36. +1 −1 config/deploy/shared/recipes/deploy.rb
  37. +0 −19 config/deploy/shared/recipes/ops.rb
  38. +1 −1 config/deploy/shared/sync
  39. +3 −0 config/deploy/shared/tasks.rb
  40. +0 −15 config/deploy/staging.rb
  41. +9 −11 config/deploy/vagrant.rb
  42. +52 −0 config/environments/staging.rb
  43. +2 −0 config/initializers/queue_classic.rb
  44. +2 −12 config/initializers/setup_mail.rb
  45. +1 −3 config/routes.rb
  46. +2 −25 config/schedule.rb
  47. +1 −1 db/migrate/20120525003832_add_unauth_rsvp_to_distributions.rb
  48. +7 −1 db/migrate/20120531131003_rename_date_fields.rb
  49. +12 −0 db/migrate/20120603215230_add_queue_classic.rb
  50. +10 −1 db/schema.rb
  51. +43 −14 lib/env_settings.rb
  52. +2 −3 lib/{development_mail_interceptor.rb → mail_interceptor.rb}
  53. +19 −39 lib/tasks/backups.rake
  54. +6 −140 lib/tasks/mail.rake
  55. +2 −0 lib/tasks/queue_classic.rake
  56. +26 −0 script/alertmail
  57. +17 −0 script/enqueue
  58. +3 −0 script/tmpro
  59. BIN vendor/cache/aws-ses-0.4.4.gem
  60. BIN vendor/cache/queue_classic-2.0.0.gem
  61. BIN vendor/cache/scrolls-0.0.9.gem
  62. BIN vendor/cache/xml-simple-1.1.1.gem
View
1 .env
@@ -1 +0,0 @@
-RAILS_ENV=production
View
@@ -5,6 +5,7 @@
.sass-cache
.sass-cache/*
.sass-cache/**/*
+.rbenv-vars-*
log
log/*
db/data.yml
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -14,6 +14,7 @@
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.sass-cache" />
+ <excludeFolder url="file://$MODULE_DIR$/bin" />
<excludeFolder url="file://$MODULE_DIR$/log" />
<excludeFolder url="file://$MODULE_DIR$/public/assets" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
@@ -113,6 +114,7 @@
<orderEntry type="library" scope="PROVIDED" name="pngqr (v0.6, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="polyglot (v0.3.3, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="prawn (v0.12.0, ruby-1.9.3-p194) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="queue_classic (v2.0.0, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rabl (v0.6.12, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack (v1.3.6, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-cache (v1.2, ruby-1.9.3-p194) [gem]" level="application" />
@@ -136,6 +138,7 @@
<orderEntry type="library" scope="PROVIDED" name="ruby-rc4 (v0.1.5, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rubyzip (v0.9.8, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sass (v3.1.19, ruby-1.9.3-p194) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="scrolls (v0.0.9, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="selenium-webdriver (v2.22.0, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sequel (v3.31.0, ruby-1.9.3-p194) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="shared-mime-info (v0.1, ruby-1.9.3-p194) [gem]" level="application" />
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
- <component name="DataSourceManagerImpl" compressed="false" hash="1836422682" />
+ <component name="DataSourceManagerImpl" compressed="false" hash="882463089" />
</project>
View
@@ -0,0 +1,11 @@
+APP_NAME=bnet
+
+# default environment - automatically changed during deployment
+RAILS_ENV=development
+
+# queue_classic variables
+QC_DATABASE_URL=postgres://bnet:${POSTGRES_PASS}@localhost/bnet_${RAILS_ENV}
+QC_LISTENING_WORKER=true
+
+# for testing in development
+BROWSER=firefox
View
@@ -1 +1 @@
-{"active":{"default":"67cd342b-effe-4402-b49c-075df326d060","bnetv":"3bcf7068-a796-4087-862b-d52e22539839","vagrant":"cfbaea3b-33af-424a-8816-046155dd6fc8"}}
+{"active":{"default":"67cd342b-effe-4402-b49c-075df326d060","bnetv":"3bcf7068-a796-4087-862b-d52e22539839","vagrant":"1d9c7a49-0188-4892-afa6-d1a91a3ac076"}}
View
38 Capfile
@@ -6,41 +6,43 @@ require File.expand_path('./lib/env_settings', File.dirname(__FILE__))
set :app_name, APP_NAME # <- this comes from lib/env_settings
set :application, "BAMRU-Private"
set :repository, "https://github.com/andyl/#{application}.git"
-set :vhost_names, %w(bnet bnettest)
+set :vhost_names, %w(bamru1 bnet www.bamru.net bamru.net)
set :web_port, 8500
# ===== Stage-Specific Code =====
-stage = "production" # <--- set to one of [vagrant|staging|production]
-require File.expand_path("config/deploy/#{stage}", File.dirname(__FILE__))
+set :stages, %w(vagrant devstage pubstage production)
+set :default_stage, "production"
+require 'capistrano/ext/multistage'
# ===== Common Code for All Stages =====
load 'deploy'
-base_dir = File.expand_path(File.dirname(__FILE__))
-Dir.glob("config/deploy/shared/base/*.rb").each {|f| require base_dir + '/' + f}
-Dir.glob("config/deploy/shared/recipes/*.rb").each {|f| require base_dir + '/' + f}
+share_dir = File.expand_path("config/deploy/shared", File.dirname(__FILE__))
+require "#{share_dir}/tasks"
# ===== Package Definitions =====
-require base_dir + "/config/deploy/shared/packages/passenger" # nginx config
-require base_dir + "/config/deploy/shared/packages/foreman" # foreman processes managed by upstart
-require base_dir + "/config/deploy/shared/packages/sqlite" # shared sqlite script
-require base_dir + "/config/deploy/shared/packages/postgresql"
+require share_dir + "/packages/cron" # setup cron using whenever
+require share_dir + "/packages/passenger" # nginx config
+require share_dir + "/packages/foreman" # foreman processes managed by upstart
+require share_dir + "/packages/sqlite" # shared sqlite script
+require share_dir + "/packages/postgresql" # postgres database
+require share_dir + "/packages/monit" # setup monit_alert
# ===== App-Specific Tasks =====
# ----- keys -----
-before 'deploy:setup', 'keys:upload'
+after 'deploy:update_code', 'keys:upload'
namespace :keys do
desc "upload keys"
task :upload do
- file = ".bnet_environment.yaml"
- keyfile = File.expand_path("~/#{file}")
- keytext = File.read(keyfile)
- tgtfile = "/home/#{user}/#{file}"
- put keytext, tgtfile
- run "chown -R #{user} #{tgtfile}"
- run "chgrp -R #{user} #{tgtfile}"
+ if File.exist? ".rbenv-vars-private"
+ txt = File.read(".rbenv-vars-private")
+ put txt, "#{release_path}/.rbenv-vars-private"
+ else
+ puts " WARNING - no private keyfile ".center(80, '*')
+ end
+
end
end
View
@@ -17,10 +17,14 @@ gem "ancestry"
gem "haml-rails"
gem "net-ssh", "2.2.2"
+gem "queue_classic"
+
gem "yaml_db"
gem "pg"
+gem "aws-ses", :require => "aws/ses"
+
gem "fastercsv"
gem "nokogiri"
gem "simple_form"
View
@@ -58,6 +58,11 @@ GEM
archive-tar-minitar (0.5.2)
arel (2.2.3)
awesome_print (1.0.2)
+ aws-ses (0.4.4)
+ builder
+ mail (> 2.2.5)
+ mime-types
+ xml-simple
bcrypt-ruby (3.0.1)
blankslate (2.1.2.4)
builder (3.0.0)
@@ -214,6 +219,9 @@ GEM
prawn (0.12.0)
pdf-reader (>= 0.9.0)
ttfunk (~> 1.0.2)
+ queue_classic (2.0.0)
+ pg (~> 0.13.2)
+ scrolls (~> 0.0.8)
rabl (0.6.12)
activesupport (>= 2.3.14)
multi_json (~> 1.0)
@@ -268,6 +276,7 @@ GEM
ruby-rc4 (0.1.5)
rubyzip (0.9.8)
sass (3.1.19)
+ scrolls (0.0.9)
selenium-webdriver (2.22.0)
childprocess (>= 0.2.5)
ffi (~> 1.0)
@@ -331,6 +340,7 @@ GEM
activesupport (>= 2.3.4)
chronic (~> 0.6.3)
wirble (0.1.3)
+ xml-simple (1.1.1)
xpath (0.1.4)
nokogiri (~> 1.3)
yaml_db (0.2.3)
@@ -343,6 +353,7 @@ DEPENDENCIES
ancestry
annotate!
awesome_print
+ aws-ses
bcrypt-ruby (~> 3.0.0)
cancan
capistrano
@@ -385,6 +396,7 @@ DEPENDENCIES
pg
pngqr
prawn
+ queue_classic
rabl
rack-offline
rails (= 3.1.3)
View
@@ -1,3 +1,4 @@
web: bin/passenger start -p $PORT
faye: bundle exec rackup faye.ru -s thin -E production
perfd: script/perfd
+qcwork: bundle exec rake qc:work --trace
View
@@ -1,2 +1,3 @@
faye: bundle exec rackup faye.ru -s thin -E production
perfd: script/perfd
+# qcworker: bundle exec rake qc:work
View
@@ -4,48 +4,107 @@ This is the code for the BAMRU Private website.
## Maintaing and Contributing
-### Running the App
+### Target Audience
+
+To be a successful maintainer/contributor, you'll need reasonable familiarity
+with linux, git, ruby & rails. You should be comfortable with the material in
+the [UC Berkeley SAAS online class](https://www.coursera.org/course/saas).
+
+### Bootstrap & Run in Development Mode
This app has been developed on Ubuntu 12.04. It will probably work on a Mac.
-It won't run on a vanilla PC, but may work with Cygwin.
+It won't run on a vanilla PC, but may work with Cygwin.
-To run the app:
-- get the application datafiles from Andy (sqlite database, image directory, environment file)
-- clone the app & install the datafiles
-- edit database.yml to use sqlite
+To bootstrap the app:
+- get the application datafiles from Andy (database, image directory, environment file)
+- clone the repo & install the datafiles
+- install ruby 1.9.3
+- install postgres, add postgres user & password
- run `bundle install`
-- run `rails server`
+- run `rake db:create:all`
+- run `rake db:migrate`
+- run `rake db:data:load`
+
+To run the app in development:
+- run `rails server` to run just the web app
+- run `foreman start -p 3000 -e .rbenv-vars` to run the full stack
+
+### Provisioning a Server
+
+We use a combination of shell scripts and Puppet manifests to auto-configure
+the staging and production servers. Main elements of the stack include:
+- nginx - reverse proxy
+- passenger-standalone - web server
+- monit - monitoring and alerting
+- upstart - application init and auto-restart on failure
+- foreman - process initiation
+- postgres - database
+- queue-classic - background job manager
+- faye - ruby/javascript pub-sub
+- rbenv - ruby version manager
+- whenever - schedule (cron) processes
+
+See the Vagrantfile and the "bootstrap-base" shell script to learn how
+auto-provisioning is done.
### Deploying the App
-This app is built to use three deployment environments:
+This app is built to use four deployment environments:
- vagrant - for development (requires vagrant/virtualbox)
-- staging - for integration testing
+- devstage - local staging server for integration testing
+- pubstage - public staging server for integration testing
- production - the live system
-Deploying to Vagrant:
-- edit your Capfile to set the stage to 'vagrant'
+Deploying to Vagrant: Provision the Box
- create and provision the VM using `vagrant up`
- setup ssh using `vagrant ssh-config >> ~/.ssh/config`
- add 'dns lookup' using `sudo echo '192.168.33.12 vagrant' >> /etc/hosts`
-- initialze the app using `cap ops:setup`
-- upload the database using `db/upload vagrant`
-- upload the image directory using `scp -r public/system vagrant:a/BAMRU-Private/public`
+
+Deploying to Vagrant: Bootstrap & Run the App
+- edit your Capfile to set the default stage to 'vagrant'
+- initialze the app using `cap deploy:setup ; cap deploy:cold`
+- upload the images & load database using `cap data:init`
- deploy the working system using `cap deploy`
-- run a tmux-dashboard using `cap ops:console`
+- run a tmux-dashboard using `cap console`
Deploying to Staging and Production: ask Andy for instructions
+### Git Organization
+
+The Git repo is organized to roughly follow the
+[nvie guidelines](http://nvie.com/posts/a-successful-git-branching-model/).
+The main branches in the repo include:
+- master - used for production deploy
+- dev - default branch for vagrant & staging deploys
+- dev-feature - feature branch
+
+### Scheduled Tasks
+
+This system uses the 'whenever' gem to managed scheduled/cron tasks,
+including system backups and automatic notifications.
+
+See `schedule.rb` for the list of scheduled tasks.
+
+### Email Testing
+
+In development, emails are rendered to the browser on localhost,
+using the `letter_opener` gem.
+
+In staging, emails are only sent for the addresses specified in
+the STAGING_VALID_EMAILS environment variable. And also, staging
+emails are all routed to a single address, specified by the
+STAGING_DELIVERY_ADDRESS environment variable.
+
### Contributing to the App
Contributions are encouraged!
-- fork the app
+- fork the repo
- clone & edit your fork
-- make your edits in a separate branch
+- make your edits in a separate development branch
- include tests!
- send pull-requests to Andy
-### License
+## License
Copyright (c) 2011-2012 Andy Leak
Oops, something went wrong.

0 comments on commit c6e6f06

Please sign in to comment.