golden_brindle 0.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rspec +1 -0
 - data/Gemfile +11 -0
 - data/Gemfile.lock +38 -0
 - data/Rakefile +33 -46
 - data/bin/golden_brindle +1 -4
 - data/golden_brindle.gemspec +33 -15
 - data/lib/golden_brindle/actions/cluster.rb +50 -0
 - data/lib/golden_brindle/actions/configure.rb +63 -0
 - data/lib/golden_brindle/actions/restart.rb +40 -0
 - data/lib/golden_brindle/actions/start.rb +131 -0
 - data/lib/golden_brindle/actions/stop.rb +45 -0
 - data/lib/golden_brindle/base.rb +89 -0
 - data/lib/golden_brindle/command.rb +39 -174
 - data/lib/golden_brindle/const.rb +5 -5
 - data/lib/golden_brindle/hooks.rb +2 -1
 - data/lib/golden_brindle/rails_support.rb +2 -2
 - data/lib/golden_brindle/validations.rb +56 -0
 - data/lib/golden_brindle.rb +6 -7
 - data/spec/golden_brindle_spec.rb +23 -0
 - data/spec/spec_helper.rb +12 -0
 - metadata +70 -18
 - data/lib/golden_brindle/cluster.rb +0 -53
 - data/lib/golden_brindle/configure.rb +0 -63
 - data/lib/golden_brindle/restart.rb +0 -40
 - data/lib/golden_brindle/start.rb +0 -130
 - data/lib/golden_brindle/stop.rb +0 -45
 - data/test/helper.rb +0 -10
 - data/test/test_golden_brindle.rb +0 -7
 
    
        data/lib/golden_brindle.rb
    CHANGED
    
    | 
         @@ -1,14 +1,13 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'gem_plugin'
         
     | 
| 
       2 
1 
     | 
    
         
             
            require 'optparse'
         
     | 
| 
       3 
2 
     | 
    
         
             
            require 'yaml'
         
     | 
| 
       4 
3 
     | 
    
         
             
            require 'unicorn'
         
     | 
| 
       5 
4 
     | 
    
         
             
            require 'unicorn/launcher'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'golden_brindle/const'
         
     | 
| 
       7 
     | 
    
         
            -
            require 'golden_brindle/ 
     | 
| 
       8 
     | 
    
         
            -
            require 'golden_brindle/ 
     | 
| 
      
 6 
     | 
    
         
            +
            require 'golden_brindle/validations'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'golden_brindle/base'
         
     | 
| 
       9 
8 
     | 
    
         
             
            require 'golden_brindle/rails_support'
         
     | 
| 
       10 
9 
     | 
    
         
             
            require 'golden_brindle/hooks'
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            require  
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            require 'golden_brindle/ 
     | 
| 
      
 10 
     | 
    
         
            +
            Dir.glob(File.join(File.dirname(__FILE__),'golden_brindle/actions/', '*.rb')) do |action|
         
     | 
| 
      
 11 
     | 
    
         
            +
              require action
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'golden_brindle/command'
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              describe GoldenBrindle::Registry do
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                let(:commands) do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  ["start", "stop", "restart", "configure", "cluster::start", "cluster::stop", "cluster::restart"]
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                it "constantize should return proper constant" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  GoldenBrindle::Registry.constantize("GoldenBrindle::Registry").should eql GoldenBrindle::Registry
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                it "constantize should raise on broken constant" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  expect { GoldenBrindle::Registry.constantize("GoldenBrindle::Registry123")}.to raise_error
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                it "commands should return correct commands" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                  GoldenBrindle::Registry.commands.should =~ commands
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         
     | 
| 
      
 2 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'golden_brindle'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Requires supporting files with custom matchers and macros, etc,
         
     | 
| 
      
 7 
     | 
    
         
            +
            # in ./support/ and its subdirectories.
         
     | 
| 
      
 8 
     | 
    
         
            +
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 11 
     | 
    
         
            +
              
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            name: golden_brindle
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
4 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       5 
     | 
    
         
            -
              version: "0. 
     | 
| 
      
 5 
     | 
    
         
            +
              version: "0.3"
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors: 
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Alexander Simonov
         
     | 
| 
         @@ -10,31 +10,75 @@ autorequire: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            date: 2011-09- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2011-09-14 00:00:00 +03:00
         
     | 
| 
       14 
14 
     | 
    
         
             
            default_executable: golden_brindle
         
     | 
| 
       15 
15 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       16 
16 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       17 
     | 
    
         
            -
              name:  
     | 
| 
       18 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
      
 17 
     | 
    
         
            +
              name: unicorn
         
     | 
| 
       19 
18 
     | 
    
         
             
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
       20 
19 
     | 
    
         
             
                none: false
         
     | 
| 
       21 
20 
     | 
    
         
             
                requirements: 
         
     | 
| 
       22 
21 
     | 
    
         
             
                - - ">="
         
     | 
| 
       23 
22 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       24 
     | 
    
         
            -
                    version: 0 
     | 
| 
      
 23 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
       25 
24 
     | 
    
         
             
              type: :runtime
         
     | 
| 
      
 25 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
       26 
26 
     | 
    
         
             
              version_requirements: *id001
         
     | 
| 
       27 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
       28 
     | 
    
         
            -
              name:  
     | 
| 
       29 
     | 
    
         
            -
              prerelease: false
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rspec
         
     | 
| 
       30 
29 
     | 
    
         
             
              requirement: &id002 !ruby/object:Gem::Requirement 
         
     | 
| 
       31 
30 
     | 
    
         
             
                none: false
         
     | 
| 
       32 
31 
     | 
    
         
             
                requirements: 
         
     | 
| 
       33 
32 
     | 
    
         
             
                - - ">="
         
     | 
| 
       34 
33 
     | 
    
         
             
                  - !ruby/object:Gem::Version 
         
     | 
| 
       35 
     | 
    
         
            -
                    version: " 
     | 
| 
       36 
     | 
    
         
            -
              type: : 
     | 
| 
      
 34 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 35 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 36 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
       37 
37 
     | 
    
         
             
              version_requirements: *id002
         
     | 
| 
      
 38 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 39 
     | 
    
         
            +
              name: yard
         
     | 
| 
      
 40 
     | 
    
         
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 41 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 45 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 46 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 47 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 48 
     | 
    
         
            +
              version_requirements: *id003
         
     | 
| 
      
 49 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 50 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 51 
     | 
    
         
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 52 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 53 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 54 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 55 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 56 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 57 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 58 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 59 
     | 
    
         
            +
              version_requirements: *id004
         
     | 
| 
      
 60 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 61 
     | 
    
         
            +
              name: jeweler
         
     | 
| 
      
 62 
     | 
    
         
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 63 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 64 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 65 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 66 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 67 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 68 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 69 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 70 
     | 
    
         
            +
              version_requirements: *id005
         
     | 
| 
      
 71 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 72 
     | 
    
         
            +
              name: rcov
         
     | 
| 
      
 73 
     | 
    
         
            +
              requirement: &id006 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 74 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 75 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 76 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 77 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 78 
     | 
    
         
            +
                    version: "0"
         
     | 
| 
      
 79 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 80 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 81 
     | 
    
         
            +
              version_requirements: *id006
         
     | 
| 
       38 
82 
     | 
    
         
             
            description: Unicorn HTTP server multiple application runner tool
         
     | 
| 
       39 
83 
     | 
    
         
             
            email: alex@simonov.me
         
     | 
| 
       40 
84 
     | 
    
         
             
            executables: 
         
     | 
| 
         @@ -47,7 +91,10 @@ extra_rdoc_files: 
     | 
|
| 
       47 
91 
     | 
    
         
             
            - TODO
         
     | 
| 
       48 
92 
     | 
    
         
             
            files: 
         
     | 
| 
       49 
93 
     | 
    
         
             
            - .document
         
     | 
| 
      
 94 
     | 
    
         
            +
            - .rspec
         
     | 
| 
       50 
95 
     | 
    
         
             
            - COPYING
         
     | 
| 
      
 96 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 97 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
       51 
98 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       52 
99 
     | 
    
         
             
            - README.rdoc
         
     | 
| 
       53 
100 
     | 
    
         
             
            - Rakefile
         
     | 
| 
         @@ -56,22 +103,24 @@ files: 
     | 
|
| 
       56 
103 
     | 
    
         
             
            - bin/golden_brindle
         
     | 
| 
       57 
104 
     | 
    
         
             
            - golden_brindle.gemspec
         
     | 
| 
       58 
105 
     | 
    
         
             
            - lib/golden_brindle.rb
         
     | 
| 
       59 
     | 
    
         
            -
            - lib/golden_brindle/cluster.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
            - lib/golden_brindle/actions/cluster.rb
         
     | 
| 
      
 107 
     | 
    
         
            +
            - lib/golden_brindle/actions/configure.rb
         
     | 
| 
      
 108 
     | 
    
         
            +
            - lib/golden_brindle/actions/restart.rb
         
     | 
| 
      
 109 
     | 
    
         
            +
            - lib/golden_brindle/actions/start.rb
         
     | 
| 
      
 110 
     | 
    
         
            +
            - lib/golden_brindle/actions/stop.rb
         
     | 
| 
      
 111 
     | 
    
         
            +
            - lib/golden_brindle/base.rb
         
     | 
| 
       60 
112 
     | 
    
         
             
            - lib/golden_brindle/command.rb
         
     | 
| 
       61 
     | 
    
         
            -
            - lib/golden_brindle/configure.rb
         
     | 
| 
       62 
113 
     | 
    
         
             
            - lib/golden_brindle/const.rb
         
     | 
| 
       63 
114 
     | 
    
         
             
            - lib/golden_brindle/hooks.rb
         
     | 
| 
       64 
115 
     | 
    
         
             
            - lib/golden_brindle/rails_support.rb
         
     | 
| 
       65 
     | 
    
         
            -
            - lib/golden_brindle/ 
     | 
| 
       66 
     | 
    
         
            -
            - lib/golden_brindle/start.rb
         
     | 
| 
       67 
     | 
    
         
            -
            - lib/golden_brindle/stop.rb
         
     | 
| 
      
 116 
     | 
    
         
            +
            - lib/golden_brindle/validations.rb
         
     | 
| 
       68 
117 
     | 
    
         
             
            - resources/golden_brindle
         
     | 
| 
       69 
     | 
    
         
            -
            -  
     | 
| 
       70 
     | 
    
         
            -
            -  
     | 
| 
      
 118 
     | 
    
         
            +
            - spec/golden_brindle_spec.rb
         
     | 
| 
      
 119 
     | 
    
         
            +
            - spec/spec_helper.rb
         
     | 
| 
       71 
120 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       72 
121 
     | 
    
         
             
            homepage: http://github.com/simonoff/golden_brindle
         
     | 
| 
       73 
     | 
    
         
            -
            licenses:  
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 122 
     | 
    
         
            +
            licenses: 
         
     | 
| 
      
 123 
     | 
    
         
            +
            - GPL2
         
     | 
| 
       75 
124 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       76 
125 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       77 
126 
     | 
    
         | 
| 
         @@ -82,6 +131,9 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       82 
131 
     | 
    
         
             
              requirements: 
         
     | 
| 
       83 
132 
     | 
    
         
             
              - - ">="
         
     | 
| 
       84 
133 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 134 
     | 
    
         
            +
                  hash: -123107741511934714
         
     | 
| 
      
 135 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 136 
     | 
    
         
            +
                  - 0
         
     | 
| 
       85 
137 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       86 
138 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       87 
139 
     | 
    
         
             
              none: false
         
     | 
| 
         @@ -1,53 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            module Cluster
         
     | 
| 
       3 
     | 
    
         
            -
              
         
     | 
| 
       4 
     | 
    
         
            -
              module Base
         
     | 
| 
       5 
     | 
    
         
            -
                include GoldenBrindle::Command::Base
         
     | 
| 
       6 
     | 
    
         
            -
                
         
     | 
| 
       7 
     | 
    
         
            -
                def configure 
         
     | 
| 
       8 
     | 
    
         
            -
                  options [ 
         
     | 
| 
       9 
     | 
    
         
            -
                    ["-c", "--conf_path PATH", "Path to golden_brindle configuration files", :@cwd, "."],
         
     | 
| 
       10 
     | 
    
         
            -
                    ["-V", "", "Verbose output", :@verbose, false]
         
     | 
| 
       11 
     | 
    
         
            -
                  ]
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
                
         
     | 
| 
       14 
     | 
    
         
            -
                def validate
         
     | 
| 
       15 
     | 
    
         
            -
                  @cwd = File.expand_path(@cwd)
         
     | 
| 
       16 
     | 
    
         
            -
                  valid_dir? @cwd, "Invalid path to golden_brindle configuration files: #{@cwd}"
         
     | 
| 
       17 
     | 
    
         
            -
                  @valid
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                def run
         
     | 
| 
       21 
     | 
    
         
            -
                  command = self.class.to_s.downcase.split('::')[1]
         
     | 
| 
       22 
     | 
    
         
            -
                  counter = 0
         
     | 
| 
       23 
     | 
    
         
            -
                  errors = 0
         
     | 
| 
       24 
     | 
    
         
            -
                  Dir.chdir @cwd do
         
     | 
| 
       25 
     | 
    
         
            -
                    Dir.glob("**/*.{yml,conf}").each do |conf|
         
     | 
| 
       26 
     | 
    
         
            -
                      cmd = "golden_brindle #{command} -C #{conf}"
         
     | 
| 
       27 
     | 
    
         
            -
                      cmd += " -d" if command == "start" #daemonize only when start
         
     | 
| 
       28 
     | 
    
         
            -
                      puts cmd if @verbose 
         
     | 
| 
       29 
     | 
    
         
            -
                      output = `#{cmd}`
         
     | 
| 
       30 
     | 
    
         
            -
                      puts output if @verbose
         
     | 
| 
       31 
     | 
    
         
            -
                      status = $?.success?
         
     | 
| 
       32 
     | 
    
         
            -
                      puts "golden_brindle #{command} returned an error." unless status
         
     | 
| 
       33 
     | 
    
         
            -
                      status ? counter += 1 : errors += 1
         
     | 
| 
       34 
     | 
    
         
            -
                    end
         
     | 
| 
       35 
     | 
    
         
            -
                  end
         
     | 
| 
       36 
     | 
    
         
            -
                  puts "Success:#{counter}; Errors: #{errors}"
         
     | 
| 
       37 
     | 
    
         
            -
                end
         
     | 
| 
       38 
     | 
    
         
            -
                
         
     | 
| 
       39 
     | 
    
         
            -
              end
         
     | 
| 
       40 
     | 
    
         
            -
              
         
     | 
| 
       41 
     | 
    
         
            -
              class Start < GemPlugin::Plugin "/commands"
         
     | 
| 
       42 
     | 
    
         
            -
                include Cluster::Base
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
              
         
     | 
| 
       45 
     | 
    
         
            -
              class Stop < GemPlugin::Plugin "/commands"
         
     | 
| 
       46 
     | 
    
         
            -
                include Cluster::Base
         
     | 
| 
       47 
     | 
    
         
            -
              end
         
     | 
| 
       48 
     | 
    
         
            -
              
         
     | 
| 
       49 
     | 
    
         
            -
              class Restart < GemPlugin::Plugin "/commands"
         
     | 
| 
       50 
     | 
    
         
            -
                include Cluster::Base
         
     | 
| 
       51 
     | 
    
         
            -
              end
         
     | 
| 
       52 
     | 
    
         
            -
              
         
     | 
| 
       53 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,63 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Brindle
         
     | 
| 
       2 
     | 
    
         
            -
              
         
     | 
| 
       3 
     | 
    
         
            -
              class Configure < GemPlugin::Plugin "/commands"
         
     | 
| 
       4 
     | 
    
         
            -
                include GoldenBrindle::Command::Base
         
     | 
| 
       5 
     | 
    
         
            -
                
         
     | 
| 
       6 
     | 
    
         
            -
                def configure
         
     | 
| 
       7 
     | 
    
         
            -
                    options [
         
     | 
| 
       8 
     | 
    
         
            -
                      ["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"],
         
     | 
| 
       9 
     | 
    
         
            -
                      ["-d", "--daemonize", "Run daemonized in the background", :@daemon, false],
         
     | 
| 
       10 
     | 
    
         
            -
                      ["-b", "--bundler", "Use bundler to start unicorn instances", :@bundler, false],
         
     | 
| 
       11 
     | 
    
         
            -
                      ['', "--preload", "Preload application", :@preload, false],
         
     | 
| 
       12 
     | 
    
         
            -
                      ['-p', '--port PORT', "Which port to bind to (if set numbers of servers - start port number)", :@port, Unicorn::Const::DEFAULT_PORT],
         
     | 
| 
       13 
     | 
    
         
            -
                      ['-a', '--address ADDR', "Address to bind to", :@address, Unicorn::Const::DEFAULT_HOST],
         
     | 
| 
       14 
     | 
    
         
            -
                      ['-o', '--listen {HOST:PORT|PATH}',"listen on HOST:PORT or PATH, separated by comma ", :@listen, nil] ,
         
     | 
| 
       15 
     | 
    
         
            -
                      ['-l', '--log FILE', "Where to write log messages", :@log_file, "log/unicorn.log"],
         
     | 
| 
       16 
     | 
    
         
            -
                      ['-P', '--pid FILE', "Where to write the PID", :@pid_file, "tmp/pids/unicorn.pid"],
         
     | 
| 
       17 
     | 
    
         
            -
                      ['-n', '--num-workers INT', "Number of Unicorn workers", :@workers, 4],
         
     | 
| 
       18 
     | 
    
         
            -
                      ['-N', '--num-servers INT', "Number of Unicorn listen records", :@servers, 1],
         
     | 
| 
       19 
     | 
    
         
            -
                      ['-t', '--timeout INT', "Time to wait (in seconds) before killing a stalled thread", :@timeout, 60],
         
     | 
| 
       20 
     | 
    
         
            -
                      ['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd],
         
     | 
| 
       21 
     | 
    
         
            -
                      ['-D', '--debug', "Enable debugging mode", :@debug, false],
         
     | 
| 
       22 
     | 
    
         
            -
                      ['-C', '--config PATH', "Path to brindle configuration file", :@config_file, "config/brindle.yml"],
         
     | 
| 
       23 
     | 
    
         
            -
                      ['-S', '--script PATH', "Load the Unicorn-specific config file", :@config_script, nil],
         
     | 
| 
       24 
     | 
    
         
            -
                      ['', '--user USER', "User to run as", :@user, nil],
         
     | 
| 
       25 
     | 
    
         
            -
                      ['', '--group GROUP', "Group to run as", :@group, nil],
         
     | 
| 
       26 
     | 
    
         
            -
                      ['', '--prefix PATH', "URL prefix for Rails app", :@prefix, nil]
         
     | 
| 
       27 
     | 
    
         
            -
                    ]
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
                
         
     | 
| 
       30 
     | 
    
         
            -
                def validate
         
     | 
| 
       31 
     | 
    
         
            -
                  
         
     | 
| 
       32 
     | 
    
         
            -
                  valid_dir? File.dirname(@config_file), "Path to config file not valid: #{@config_file}"
         
     | 
| 
       33 
     | 
    
         
            -
                  
         
     | 
| 
       34 
     | 
    
         
            -
                  if @config_script
         
     | 
| 
       35 
     | 
    
         
            -
                    valid_exists?(@config_script, "Unicorn-specific config file not there: #{@config_script}")
         
     | 
| 
       36 
     | 
    
         
            -
                    return false unless @valid
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                  valid?(@prefix[0] == ?/ && @prefix[-1] != ?/, "Prefix must begin with / and not end in /") if @prefix
         
     | 
| 
       40 
     | 
    
         
            -
                  valid_dir? File.dirname(@log_file), "Path to log file not valid: #@log_file"
         
     | 
| 
       41 
     | 
    
         
            -
                  valid_dir? File.dirname(@pid_file), "Path to pid file not valid: #@pid_file"
         
     | 
| 
       42 
     | 
    
         
            -
                  valid_user? @user if @user
         
     | 
| 
       43 
     | 
    
         
            -
                  valid_group? @group if @group
         
     | 
| 
       44 
     | 
    
         
            -
                  @valid
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
                
         
     | 
| 
       47 
     | 
    
         
            -
                def run
         
     | 
| 
       48 
     | 
    
         
            -
                  
         
     | 
| 
       49 
     | 
    
         
            -
                  file_options = {}
         
     | 
| 
       50 
     | 
    
         
            -
                  
         
     | 
| 
       51 
     | 
    
         
            -
                  self.config_keys.each do |key|
         
     | 
| 
       52 
     | 
    
         
            -
                    key_val = self.instance_variable_get "@#{key}"
         
     | 
| 
       53 
     | 
    
         
            -
                    file_options[key] = key_val unless key_val.nil?
         
     | 
| 
       54 
     | 
    
         
            -
                  end
         
     | 
| 
       55 
     | 
    
         
            -
                    
         
     | 
| 
       56 
     | 
    
         
            -
                  $stdout.puts "Writing configuration file to #{@config_file}."
         
     | 
| 
       57 
     | 
    
         
            -
                  File.open(@config_file,"w") {|f| f.write(file_options.to_yaml)}
         
     | 
| 
       58 
     | 
    
         
            -
                  
         
     | 
| 
       59 
     | 
    
         
            -
                end
         
     | 
| 
       60 
     | 
    
         
            -
                
         
     | 
| 
       61 
     | 
    
         
            -
              end
         
     | 
| 
       62 
     | 
    
         
            -
              
         
     | 
| 
       63 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,40 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Brindle
         
     | 
| 
       2 
     | 
    
         
            -
              
         
     | 
| 
       3 
     | 
    
         
            -
              class Restart < GemPlugin::Plugin "/commands"
         
     | 
| 
       4 
     | 
    
         
            -
                include GoldenBrindle::Command::Base
         
     | 
| 
       5 
     | 
    
         
            -
                
         
     | 
| 
       6 
     | 
    
         
            -
                def configure 
         
     | 
| 
       7 
     | 
    
         
            -
                  options [ 
         
     | 
| 
       8 
     | 
    
         
            -
                    ['-c', '--chdir PATH', "Change to dir before starting (will be expanded).", :@cwd, "."],
         
     | 
| 
       9 
     | 
    
         
            -
                    ['-C', '--config PATH', "Use a mongrel based config file", :@config_file, nil],
         
     | 
| 
       10 
     | 
    
         
            -
                    ['-s', '--soft', "Do a soft restart rather than a process exit restart", :@soft, false],
         
     | 
| 
       11 
     | 
    
         
            -
                    ['-P', '--pid FILE', "Where the PID file is located.", :@pid_file, "tmp/pids/unicorn.pid"]
         
     | 
| 
       12 
     | 
    
         
            -
                  ]
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                def validate
         
     | 
| 
       16 
     | 
    
         
            -
                  if @config_file
         
     | 
| 
       17 
     | 
    
         
            -
                    valid_exists?(@config_file, "Config file not there: #@config_file")
         
     | 
| 
       18 
     | 
    
         
            -
                    return false unless @valid
         
     | 
| 
       19 
     | 
    
         
            -
                    @config_file = File.expand_path(@config_file)
         
     | 
| 
       20 
     | 
    
         
            -
                    load_config
         
     | 
| 
       21 
     | 
    
         
            -
                    return false unless @valid
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
       23 
     | 
    
         
            -
                  
         
     | 
| 
       24 
     | 
    
         
            -
                  @cwd = File.expand_path(@cwd)
         
     | 
| 
       25 
     | 
    
         
            -
                  valid_dir? @cwd, "Invalid path to application dir: #@cwd"
         
     | 
| 
       26 
     | 
    
         
            -
                  valid_exists? File.join(@cwd,@pid_file), "PID file #@pid_file does not exist.  Not running?"
         
     | 
| 
       27 
     | 
    
         
            -
                  @valid
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                def run
         
     | 
| 
       31 
     | 
    
         
            -
                  if @soft
         
     | 
| 
       32 
     | 
    
         
            -
                    GoldenBrindle::send_signal("HUP", File.join(@cwd,@pid_file))
         
     | 
| 
       33 
     | 
    
         
            -
                  else
         
     | 
| 
       34 
     | 
    
         
            -
                    GoldenBrindle::send_signal("USR2", File.join(@cwd,@pid_file))
         
     | 
| 
       35 
     | 
    
         
            -
                  end
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
                
         
     | 
| 
       38 
     | 
    
         
            -
              end
         
     | 
| 
       39 
     | 
    
         
            -
              
         
     | 
| 
       40 
     | 
    
         
            -
            end
         
     | 
    
        data/lib/golden_brindle/start.rb
    DELETED
    
    | 
         @@ -1,130 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Brindle
         
     | 
| 
       2 
     | 
    
         
            -
              
         
     | 
| 
       3 
     | 
    
         
            -
              class Start < GemPlugin::Plugin "/commands"
         
     | 
| 
       4 
     | 
    
         
            -
                include GoldenBrindle::Command::Base
         
     | 
| 
       5 
     | 
    
         
            -
                include Hooks
         
     | 
| 
       6 
     | 
    
         
            -
                
         
     | 
| 
       7 
     | 
    
         
            -
                def configure
         
     | 
| 
       8 
     | 
    
         
            -
                  options [
         
     | 
| 
       9 
     | 
    
         
            -
                    ["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"],
         
     | 
| 
       10 
     | 
    
         
            -
                    ["-b", "--bundler", "Use bundler to start unicorn instances", :@bundler, false],
         
     | 
| 
       11 
     | 
    
         
            -
                    ["-d", "--daemonize", "Run daemonized in the background", :@daemon, false],
         
     | 
| 
       12 
     | 
    
         
            -
                    ['', "--preload", "Preload application", :@preload, false],
         
     | 
| 
       13 
     | 
    
         
            -
                    ['-p', '--port PORT', "Which port to bind to (if set numbers of servers - start port number)", :@port, Unicorn::Const::DEFAULT_PORT],
         
     | 
| 
       14 
     | 
    
         
            -
                    ['-a', '--address ADDR', "Address to bind to", :@address, Unicorn::Const::DEFAULT_HOST],
         
     | 
| 
       15 
     | 
    
         
            -
                    ['-o', '--listen {HOST:PORT|PATH}',"listen on HOST:PORT or PATH, separated by comma (default: #{Unicorn::Const::DEFAULT_LISTEN})", :@listen, Unicorn::Const::DEFAULT_LISTEN],
         
     | 
| 
       16 
     | 
    
         
            -
                    ['-l', '--log FILE', "Where to write log messages", :@log_file, "log/unicorn.log"],
         
     | 
| 
       17 
     | 
    
         
            -
                    ['-P', '--pid FILE', "Where to write the PID", :@pid_file, "tmp/pids/unicorn.pid"],
         
     | 
| 
       18 
     | 
    
         
            -
                    ['-n', '--num-workers INT', "Number of Unicorn workers", :@workers, 4],
         
     | 
| 
       19 
     | 
    
         
            -
                    ['-N', '--num-servers INT', "Number of Unicorn listen records", :@servers, 1],
         
     | 
| 
       20 
     | 
    
         
            -
                    ['-t', '--timeout INT', "Time to wait (in seconds) before killing a stalled thread", :@timeout, 60],
         
     | 
| 
       21 
     | 
    
         
            -
                    ['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd],
         
     | 
| 
       22 
     | 
    
         
            -
                    ['-D', '--debug', "Enable debugging mode", :@debug, false],
         
     | 
| 
       23 
     | 
    
         
            -
                    ['-C', '--config PATH', "Use a mongrel based config file", :@config_file, nil],
         
     | 
| 
       24 
     | 
    
         
            -
                    ['-S', '--script PATH', "Load the Unicorn-specific config file", :@config_script, nil],
         
     | 
| 
       25 
     | 
    
         
            -
                    ['', '--user USER', "User to run as", :@user, nil],
         
     | 
| 
       26 
     | 
    
         
            -
                    ['', '--group GROUP', "Group to run as", :@group, nil],
         
     | 
| 
       27 
     | 
    
         
            -
                    ['', '--prefix PATH', "URL prefix for Rails app", :@prefix, nil]
         
     | 
| 
       28 
     | 
    
         
            -
                  ]
         
     | 
| 
       29 
     | 
    
         
            -
                end
         
     | 
| 
       30 
     | 
    
         
            -
                
         
     | 
| 
       31 
     | 
    
         
            -
                def validate
         
     | 
| 
       32 
     | 
    
         
            -
                  if @config_file
         
     | 
| 
       33 
     | 
    
         
            -
                    valid_exists?(@config_file, "Config file not there: #@config_file")
         
     | 
| 
       34 
     | 
    
         
            -
                    return false unless @valid
         
     | 
| 
       35 
     | 
    
         
            -
                    @config_file = File.expand_path(@config_file)
         
     | 
| 
       36 
     | 
    
         
            -
                    load_config
         
     | 
| 
       37 
     | 
    
         
            -
                    return false unless @valid
         
     | 
| 
       38 
     | 
    
         
            -
                  end
         
     | 
| 
       39 
     | 
    
         
            -
                  
         
     | 
| 
       40 
     | 
    
         
            -
                  if @config_script
         
     | 
| 
       41 
     | 
    
         
            -
                    valid_exists?(@config_script, "Unicorn-specific config file not there: #@config_script")
         
     | 
| 
       42 
     | 
    
         
            -
                    return false unless @valid
         
     | 
| 
       43 
     | 
    
         
            -
                  end
         
     | 
| 
       44 
     | 
    
         
            -
                  
         
     | 
| 
       45 
     | 
    
         
            -
                  if @bundler
         
     | 
| 
       46 
     | 
    
         
            -
                    valid_exists?('Gemfile', "Cannot use Bundler - no Gemfile in your application root dir")
         
     | 
| 
       47 
     | 
    
         
            -
                    return false unless @valid
         
     | 
| 
       48 
     | 
    
         
            -
                  end
         
     | 
| 
       49 
     | 
    
         
            -
                  
         
     | 
| 
       50 
     | 
    
         
            -
                  @cwd = File.expand_path(@cwd)
         
     | 
| 
       51 
     | 
    
         
            -
                  valid_dir? @cwd, "Invalid path to change to during daemon mode: #{@cwd}"
         
     | 
| 
       52 
     | 
    
         
            -
                  valid?(@prefix[0] == ?/ && @prefix[-1] != ?/, "Prefix must begin with / and not end in /") if @prefix
         
     | 
| 
       53 
     | 
    
         
            -
                  valid_dir? File.dirname(File.join(@cwd,@log_file)), "Path to log file not valid: #{@log_file}"
         
     | 
| 
       54 
     | 
    
         
            -
                  valid_dir? File.dirname(File.join(@cwd,@pid_file)), "Path to pid file not valid: #{@pid_file}"
         
     | 
| 
       55 
     | 
    
         
            -
                  valid_user? @user if @user
         
     | 
| 
       56 
     | 
    
         
            -
                  valid_group? @group if @group
         
     | 
| 
       57 
     | 
    
         
            -
                  @valid
         
     | 
| 
       58 
     | 
    
         
            -
                end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                def default_options
         
     | 
| 
       61 
     | 
    
         
            -
                  {
         
     | 
| 
       62 
     | 
    
         
            -
                    :listeners          => [],
         
     | 
| 
       63 
     | 
    
         
            -
                    :pid                => @pid_file,
         
     | 
| 
       64 
     | 
    
         
            -
                    :config_file        => @config_script,
         
     | 
| 
       65 
     | 
    
         
            -
                    :worker_processes   => @workers.to_i,
         
     | 
| 
       66 
     | 
    
         
            -
                    :working_directory  => @cwd,
         
     | 
| 
       67 
     | 
    
         
            -
                    :timeout            => @timeout.to_i
         
     | 
| 
       68 
     | 
    
         
            -
                  }
         
     | 
| 
       69 
     | 
    
         
            -
                end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                def bundler_cmd
         
     | 
| 
       72 
     | 
    
         
            -
                  cmd = "bundle exec #{@opt.program_name}"
         
     | 
| 
       73 
     | 
    
         
            -
                  @original_args.each_slice(2) do |arg_key,value|
         
     | 
| 
       74 
     | 
    
         
            -
                    cmd << " #{arg_key} #{value}" if arg_key != "-b"
         
     | 
| 
       75 
     | 
    
         
            -
                  end
         
     | 
| 
       76 
     | 
    
         
            -
                  cmd
         
     | 
| 
       77 
     | 
    
         
            -
                end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                def collect_listeners
         
     | 
| 
       80 
     | 
    
         
            -
                  return if @port.nil?
         
     | 
| 
       81 
     | 
    
         
            -
                  start_port = end_port = nil
         
     | 
| 
       82 
     | 
    
         
            -
                  start_port ||=  @port.to_i
         
     | 
| 
       83 
     | 
    
         
            -
                  end_port ||=  start_port + @servers.to_i - 1
         
     | 
| 
       84 
     | 
    
         
            -
                  (start_port..end_port).map do |port|
         
     | 
| 
       85 
     | 
    
         
            -
                    "#{@address}:#{port}"
         
     | 
| 
       86 
     | 
    
         
            -
                  end
         
     | 
| 
       87 
     | 
    
         
            -
                end
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                def parse_listen_option
         
     | 
| 
       90 
     | 
    
         
            -
                  return if @listen.nil? || @listen.empty?
         
     | 
| 
       91 
     | 
    
         
            -
                  @listen.split(',').map do |listen|
         
     | 
| 
       92 
     | 
    
         
            -
                    listen = File.join(@cwd,listen) if listen[0..0] != "/" && !listen.match(/\w+\:\w+/)
         
     | 
| 
       93 
     | 
    
         
            -
                    "#{listen}"
         
     | 
| 
       94 
     | 
    
         
            -
                  end
         
     | 
| 
       95 
     | 
    
         
            -
                end
         
     | 
| 
       96 
     | 
    
         
            -
                
         
     | 
| 
       97 
     | 
    
         
            -
                def run
         
     | 
| 
       98 
     | 
    
         
            -
                  # Change there to start, then we'll have to come back after daemonize
         
     | 
| 
       99 
     | 
    
         
            -
                  Dir.chdir(@cwd)
         
     | 
| 
       100 
     | 
    
         
            -
                  if @bundler
         
     | 
| 
       101 
     | 
    
         
            -
                    puts "Using Bundler"
         
     | 
| 
       102 
     | 
    
         
            -
                    puts "reexec via bundle exec"
         
     | 
| 
       103 
     | 
    
         
            -
                    exec(bundler_cmd)
         
     | 
| 
       104 
     | 
    
         
            -
                  end
         
     | 
| 
       105 
     | 
    
         
            -
                  options = default_options
         
     | 
| 
       106 
     | 
    
         
            -
                  # set user via Unicorn options. If we don't set group - then use only user
         
     | 
| 
       107 
     | 
    
         
            -
                  options[:user] = @user unless @user.nil? 
         
     | 
| 
       108 
     | 
    
         
            -
                  options[:stderr_path] = options[:stdout_path] = @log_file if @daemon
         
     | 
| 
       109 
     | 
    
         
            -
                  options[:preload_app] = @preload
         
     | 
| 
       110 
     | 
    
         
            -
                  options.merge!(collect_hooks)
         
     | 
| 
       111 
     | 
    
         
            -
                  ENV['RAILS_ENV'] = @environment
         
     | 
| 
       112 
     | 
    
         
            -
                  ENV['RAILS_RELATIVE_URL_ROOT'] = @prefix
         
     | 
| 
       113 
     | 
    
         
            -
                  [collect_listeners, parse_listen_option].each do |listeners|
         
     | 
| 
       114 
     | 
    
         
            -
                    options[:listeners] += listeners if listeners
         
     | 
| 
       115 
     | 
    
         
            -
                  end
         
     | 
| 
       116 
     | 
    
         
            -
                  app = RailsSupport.rails_builder(@daemon)
         
     | 
| 
       117 
     | 
    
         
            -
                  if @daemon
         
     | 
| 
       118 
     | 
    
         
            -
                    Unicorn::Launcher.daemonize!(options)
         
     | 
| 
       119 
     | 
    
         
            -
                  end
         
     | 
| 
       120 
     | 
    
         
            -
                  puts "start Unicorn v#{Unicorn::Const::UNICORN_VERSION}..."
         
     | 
| 
       121 
     | 
    
         
            -
                  if Unicorn.respond_to?(:run)
         
     | 
| 
       122 
     | 
    
         
            -
                    Unicorn.run(app, options)
         
     | 
| 
       123 
     | 
    
         
            -
                  else
         
     | 
| 
       124 
     | 
    
         
            -
                    Unicorn::HttpServer.new(app, options).start.join
         
     | 
| 
       125 
     | 
    
         
            -
                  end
         
     | 
| 
       126 
     | 
    
         
            -
                end
         
     | 
| 
       127 
     | 
    
         
            -
                
         
     | 
| 
       128 
     | 
    
         
            -
                
         
     | 
| 
       129 
     | 
    
         
            -
              end
         
     | 
| 
       130 
     | 
    
         
            -
            end
         
     |