Permalink
Browse files

Adding capistrano/lilypad to aid with deployment, README in prep for …

…0.3.0
  • Loading branch information...
winton committed Dec 7, 2009
1 parent 5ff65a1 commit c284dfc991a14663e350902d57fd11e0ac1e183d
Showing with 103 additions and 22 deletions.
  1. +70 −19 README.markdown
  2. +21 −0 lib/capistrano/lilypad.rb
  3. +3 −1 lib/lilypad/adapters/rails.rb
  4. +7 −2 lib/lilypad/adapters/sinatra.rb
  5. +2 −0 lib/rack/lilypad.rb
View
@@ -10,66 +10,117 @@ Install
sudo gem install lilypad --source http://gemcutter.org
</pre>
+Basic Usage
+-----------
+
+<pre>
+require 'lilypad'
+use Rack::Lilypad, 'hoptoad_api_key_goes_here'
+</pre>
+
Rails
-----
**config/environment.rb**
<pre>
-require 'rack/lilypad'
+require 'lilypad'
Rails::Initializer.run do |config|
- config.middleware.insert_after(ActionController::Failsafe, Rack::Lilypad, 'hoptoad_api_key_goes_here')
+ config.middleware.insert_after(ActionController::Failsafe, Rack::Lilypad)
end
-require 'rack/lilypad/rails'
+Lilypad do
+ api_key 'hoptoad_api_key_goes_here'
+ rails
+end
</pre>
Sinatra
-------
<pre>
-require 'rack/lilypad'
+require 'lilypad'
class MyApp < Sinatra::Application
- enable :raise_errors # Not needed when inheriting from Sinatra::Base
- use Rack::Lilypad, 'hoptoad_api_key_goes_here'
+ use Rack::Lilypad do
+ api_key 'hoptoad_api_key_goes_here'
+ sinatra
+ end
end
</pre>
-Filters
+Options
-------
-Don't send certain environment variables to Hoptoad.
+Below are the available options and their default values:
<pre>
-use Rack::Lilypad, 'hoptoad_api_key_goes_here' do |hoptoad|
- hoptoad.filters << %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK)
+Lilypad do
+ api_key nil
+ environments %w(production staging)
+ deploy_url 'http://hoptoadapp.com:80/deploys.txt'
+ notify_url 'http://hoptoadapp.com:80/notify_url/v2/notices'
+ filters [] # Array of environment variables to hide from Hoptoad
+ log nil # Path of Hoptoad log
+ rails # Requires the Rails adapter
+ sinatra # Requires the Sinatra adapter
end
</pre>
-Direct Access
--------------
+Error Redirection
+-----------------
+
+Conditionally redirect errors to different Hoptoad buckets.
+
+<pre>
+Lilypad do
+ api_key do |env, exception|
+ if exception.message =~ /No route matches/
+ 'hoptoad_api_key_goes_here'
+ elsif env['HTTP_USER_AGENT'] =~ /crawler/
+ 'hoptoad_api_key_goes_here'
+ else
+ 'hoptoad_api_key_goes_here'
+ end
+ end
+end
+</pre>
+
+Notify
+------
Send exceptions to Hoptoad from a rescue block.
<pre>
begin
raise 'Test'
rescue Exception => e
- Rack::Lilypad.notify(e)
+ Lilypad.notify(e)
end
</pre>
-Log
----
+Deploy
+------
+
+Send deploy notifications to Hoptoad.
-See what you are sending and receiving from Hoptoad.
+**deploy.rb**
<pre>
-use Rack::Lilypad, 'hoptoad_api_key_goes_here' do |hoptoad|
- hoptoad.log = '/var/www/log/hoptoad.log'
-end
+require 'capistrano/lilypad'
+Lilypad { api_key 'hoptoad_api_key_goes_here' }
+</pre>
+
+Or you can do it manually:
+
+<pre>
+Lilypad.deploy(
+ :environment => 'production',
+ :repository => 'git@github.com:winton/lilypad.git',
+ :revision => '8acc488967085987f0a9f2c662383119f83e1bb8',
+ :username => 'winton'
+)
</pre>
Compatibility
View
@@ -0,0 +1,21 @@
+require File.expand_path("#{File.dirname __FILE__}/../lilypad") unless defined?(::Lilypad)
+
+Capistrano::Configuration.instance(:must_exist).load do
+
+ after "deploy", "hoptoad:notify"
+ after "deploy:long", "hoptoad:notify"
+ after "deploy:migrations", "hoptoad:notify"
+
+ namespace :hoptoad do
+ desc "Notify Hoptoad of the deployment"
+ task :notify, :except => { :no_release => true } do
+ ENV['RACK_ENV'] = fetch(:rails_env, "production")
+ Lilypad.deploy(
+ :environment => ENV['RACK_ENV'],
+ :repository => repository,
+ :revision => current_revision,
+ :username => ENV['USER'] || ENV['USERNAME']
+ )
+ end
+ end
+end
@@ -36,4 +36,6 @@ def rescue_action_with_lilypad(exception)
end
end
-ActionController::Base.send(:include, Lilypad::Rails)
+if defined?(ActionController::Base)
+ ActionController::Base.send(:include, Lilypad::Rails)
+end
@@ -7,5 +7,10 @@ def self.included(base)
end
end
-Sinatra::Base.send(:include, Lilypad::Sinatra)
-Sinatra::Application.send(:include, Lilypad::Sinatra)
+if defined?(Sinatra::Base)
+ Sinatra::Base.send(:include, Lilypad::Sinatra)
+end
+
+if defined?(Sinatra::Application)
+ Sinatra::Application.send(:include, Lilypad::Sinatra)
+end
View
@@ -1,3 +1,5 @@
+require File.expand_path("#{File.dirname __FILE__}/../lilypad") unless defined?(::Lilypad)
+
module Rack
class Lilypad

0 comments on commit c284dfc

Please sign in to comment.