Module: MagicRecipes::Thin

Defined in:
lib/magic_recipes/thin.rb

Overview

Thin - Deploy-Recipes

Simple recipe to work with thin, and app configurstion / registration.

Tasks:

:reconf # => Create or Update the thin yml configuration files

:start # => Start the private_pup server

:stop # => Start the private_pup server

:restart # => Restart the private_pup server

Callbacks:

before “nginx:start”, “thin:start”

before “nginx:stop”, “thin:stop”

Class Method Summary collapse

Class Method Details

.load_into(configuration) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/magic_recipes/thin.rb', line 22

def self.load_into(configuration)
  configuration.load do
    
    set_default :thin_path,        '/etc/thin'
    
    namespace :thin do
      
      desc "rewrite thin-configurations"
      task :reconf, roles: :app do
        template "thin_app_yml.erb", "#{current_path}/config/thin_app.yml"
        run "#{sudo} rm -f #{thin_path}/thin_#{app_name}*"
        run "#{sudo} ln -sf #{current_path}/config/thin_app.yml #{thin_path}/thin_#{app_name}.yml"
      end
      
      # Start / Stop / Restart Thin
      %w[start stop restart].each do |command|
        desc "#{command} thin"
        task command, roles: :app do
          reconf
          if use_rvm
            run <<-CMD
              #{rvm_cmd} && 
              cd #{current_path} && 
              bundle exec thin #{command} -C config/thin_app.yml
            CMD
          else
            run "bundle exec thin #{command} -C config/thin_app.yml"
          end
        end
        # before "nginx:#{command}", "thin:#{command}"
      end
      
      before "nginx:start", "thin:start"
      before "nginx:stop", "thin:stop"
      
    end
    
    # eof
    
  end
end