capistrano-pumaio 0.0.4 → 0.0.5
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/Gemfile +1 -1
 - data/Gemfile.lock +2 -2
 - data/VERSION +1 -1
 - data/capistrano-pumaio.gemspec +6 -5
 - data/lib/capistrano/puma/config.rb +7 -1
 - data/lib/capistrano/puma/runit.rb +3 -1
 - data/templates/runit/config.rb.erb +3 -0
 - data/templates/runit/control-q.erb +4 -1
 - data/templates/runit/finish.erb +135 -0
 - data/templates/runit/run.erb +10 -1
 - metadata +6 -5
 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ GEM 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  net-sftp (>= 2.0.0)
         
     | 
| 
       10 
10 
     | 
    
         
             
                  net-ssh (>= 2.0.14)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  net-ssh-gateway (>= 1.1.0)
         
     | 
| 
       12 
     | 
    
         
            -
                capistrano-base_helper (0.0. 
     | 
| 
      
 12 
     | 
    
         
            +
                capistrano-base_helper (0.0.6)
         
     | 
| 
       13 
13 
     | 
    
         
             
                  capistrano (>= 2.15.5)
         
     | 
| 
       14 
14 
     | 
    
         
             
                faraday (0.8.7)
         
     | 
| 
       15 
15 
     | 
    
         
             
                  multipart-post (~> 1.1)
         
     | 
| 
         @@ -65,5 +65,5 @@ PLATFORMS 
     | 
|
| 
       65 
65 
     | 
    
         
             
            DEPENDENCIES
         
     | 
| 
       66 
66 
     | 
    
         
             
              bundler (>= 1.3.0)
         
     | 
| 
       67 
67 
     | 
    
         
             
              capistrano (>= 2.15.5)
         
     | 
| 
       68 
     | 
    
         
            -
              capistrano-base_helper (>= 0.0. 
     | 
| 
      
 68 
     | 
    
         
            +
              capistrano-base_helper (>= 0.0.6)
         
     | 
| 
       69 
69 
     | 
    
         
             
              jeweler (~> 1.8.6)
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.0.5
         
     | 
    
        data/capistrano-pumaio.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = "capistrano-pumaio"
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.0. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.0.5"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Leif Ringstad"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = "2013-07- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = "2013-07-08"
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = "Capistrano recipes for puma using runit and monit."
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.email = "leifcr@gmail.com"
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
| 
         @@ -31,6 +31,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       31 
31 
     | 
    
         
             
                "templates/monit/puma.conf.erb",
         
     | 
| 
       32 
32 
     | 
    
         
             
                "templates/runit/config.rb.erb",
         
     | 
| 
       33 
33 
     | 
    
         
             
                "templates/runit/control-q.erb",
         
     | 
| 
      
 34 
     | 
    
         
            +
                "templates/runit/finish.erb",
         
     | 
| 
       34 
35 
     | 
    
         
             
                "templates/runit/log-run.erb",
         
     | 
| 
       35 
36 
     | 
    
         
             
                "templates/runit/run.erb"
         
     | 
| 
       36 
37 
     | 
    
         
             
              ]
         
     | 
| 
         @@ -45,18 +46,18 @@ Gem::Specification.new do |s| 
     | 
|
| 
       45 
46 
     | 
    
         | 
| 
       46 
47 
     | 
    
         
             
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         
     | 
| 
       47 
48 
     | 
    
         
             
                  s.add_runtime_dependency(%q<capistrano>, [">= 2.15.5"])
         
     | 
| 
       48 
     | 
    
         
            -
                  s.add_runtime_dependency(%q<capistrano-base_helper>, [">= 0.0. 
     | 
| 
      
 49 
     | 
    
         
            +
                  s.add_runtime_dependency(%q<capistrano-base_helper>, [">= 0.0.6"])
         
     | 
| 
       49 
50 
     | 
    
         
             
                  s.add_development_dependency(%q<bundler>, [">= 1.3.0"])
         
     | 
| 
       50 
51 
     | 
    
         
             
                  s.add_development_dependency(%q<jeweler>, ["~> 1.8.6"])
         
     | 
| 
       51 
52 
     | 
    
         
             
                else
         
     | 
| 
       52 
53 
     | 
    
         
             
                  s.add_dependency(%q<capistrano>, [">= 2.15.5"])
         
     | 
| 
       53 
     | 
    
         
            -
                  s.add_dependency(%q<capistrano-base_helper>, [">= 0.0. 
     | 
| 
      
 54 
     | 
    
         
            +
                  s.add_dependency(%q<capistrano-base_helper>, [">= 0.0.6"])
         
     | 
| 
       54 
55 
     | 
    
         
             
                  s.add_dependency(%q<bundler>, [">= 1.3.0"])
         
     | 
| 
       55 
56 
     | 
    
         
             
                  s.add_dependency(%q<jeweler>, ["~> 1.8.6"])
         
     | 
| 
       56 
57 
     | 
    
         
             
                end
         
     | 
| 
       57 
58 
     | 
    
         
             
              else
         
     | 
| 
       58 
59 
     | 
    
         
             
                s.add_dependency(%q<capistrano>, [">= 2.15.5"])
         
     | 
| 
       59 
     | 
    
         
            -
                s.add_dependency(%q<capistrano-base_helper>, [">= 0.0. 
     | 
| 
      
 60 
     | 
    
         
            +
                s.add_dependency(%q<capistrano-base_helper>, [">= 0.0.6"])
         
     | 
| 
       60 
61 
     | 
    
         
             
                s.add_dependency(%q<bundler>, [">= 1.3.0"])
         
     | 
| 
       61 
62 
     | 
    
         
             
                s.add_dependency(%q<jeweler>, ["~> 1.8.6"])
         
     | 
| 
       62 
63 
     | 
    
         
             
              end
         
     | 
| 
         @@ -29,8 +29,14 @@ Capistrano::Configuration.instance(true).load do 
     | 
|
| 
       29 
29 
     | 
    
         
             
              # The remote location of puma's config file. Used by runit when starting puma
         
     | 
| 
       30 
30 
     | 
    
         
             
              _cset :puma_remote_config, File.join(shared_path, "config", "puma.rb")
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
      
 32 
     | 
    
         
            +
              # runit defaults
         
     | 
| 
      
 33 
     | 
    
         
            +
              _cset :puma_restart_interval, defer {fetch(:runit_restart_interval)}
         
     | 
| 
      
 34 
     | 
    
         
            +
              _cset :puma_restart_count, defer {fetch(:runit_restart_count)}
         
     | 
| 
      
 35 
     | 
    
         
            +
              _cset :puma_autorestart_clear_interval, defer {fetch(:runit_autorestart_clear_interval)}
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       32 
37 
     | 
    
         
             
              # runit paths
         
     | 
| 
       33 
     | 
    
         
            -
              _cset : 
     | 
| 
      
 38 
     | 
    
         
            +
              _cset :puma_runit_local_run, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../../../templates", "runit", )), "run.erb")
         
     | 
| 
      
 39 
     | 
    
         
            +
              _cset :puma_runit_local_finish, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../../../templates", "runit", )), "finish.erb")
         
     | 
| 
       34 
40 
     | 
    
         
             
              _cset :puma_runit_control_q, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../../../templates", "runit")), "control-q.erb")
         
     | 
| 
       35 
41 
     | 
    
         
             
              _cset :puma_runit_local_log_run, File.join(File.expand_path(File.join(File.dirname(__FILE__),"../../../templates", "runit")), "log-run.erb")
         
     | 
| 
       36 
42 
     | 
    
         | 
| 
         @@ -22,7 +22,9 @@ Capistrano::Configuration.instance(true).load do 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                    # Create runit config
         
     | 
| 
       24 
24 
     | 
    
         
             
                    Capistrano::RunitBase.create_service_dir(puma_runit_service_name)
         
     | 
| 
       25 
     | 
    
         
            -
                    Capistrano::BaseHelper::generate_and_upload_config( 
     | 
| 
      
 25 
     | 
    
         
            +
                    Capistrano::BaseHelper::generate_and_upload_config(puma_runit_local_run, Capistrano::RunitBase.remote_run_config_path(puma_runit_service_name))
         
     | 
| 
      
 26 
     | 
    
         
            +
                    Capistrano::BaseHelper::generate_and_upload_config(puma_runit_local_finish, Capistrano::RunitBase.remote_finish_config_path(puma_runit_service_name))
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       26 
28 
     | 
    
         
             
                    #must use quit script for stop as well
         
     | 
| 
       27 
29 
     | 
    
         
             
                    Capistrano::BaseHelper::generate_and_upload_config(puma_runit_control_q, Capistrano::RunitBase.remote_control_path(puma_runit_service_name, "q"))
         
     | 
| 
       28 
30 
     | 
    
         
             
                    Capistrano::BaseHelper::generate_and_upload_config(puma_runit_control_q, Capistrano::RunitBase.remote_control_path(puma_runit_service_name, "s"))
         
     | 
| 
         @@ -8,6 +8,9 @@ state_path '<%= c.fetch(:puma_state_file) %>' 
     | 
|
| 
       8 
8 
     | 
    
         
             
            environment '<%= "#{Capistrano::BaseHelper.environment}" %>'
         
     | 
| 
       9 
9 
     | 
    
         
             
            <%= "activate_control_app '#{c.fetch(:puma_control_url)}'" if c.fetch(:puma_activate_control_app) %>
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
            # Must preload application in case there are errors, if not, infinite restarts will happen
         
     | 
| 
      
 12 
     | 
    
         
            +
            preload_app!
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       11 
14 
     | 
    
         
             
            # TODO - fix restart block!
         
     | 
| 
       12 
15 
     | 
    
         
             
            # <%= "on_restart do"              if c.fetch(:puma_on_restart_active) %>
         
     | 
| 
       13 
16 
     | 
    
         
             
            # <%= "  puts \"Restarting puma\"" if c.fetch(:puma_on_restart_active) %>
         
     | 
| 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/bin/bash --login
         
     | 
| 
      
 2 
     | 
    
         
            +
            <% c = Capistrano::BaseHelper.get_capistrano_instance %>
         
     | 
| 
      
 3 
     | 
    
         
            +
            # Announcing stop/abort
         
     | 
| 
      
 4 
     | 
    
         
            +
            echo "<%= "User: #{c.fetch(:user)} Application: #{c.fetch(:application)} Service: #{c.fetch(:puma_runit_service_name)}" %> stopping..."
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       2 
6 
     | 
    
         
             
            # The command used when puma is asked to quit/stop/exit, overridden here, as runit normal signal will not work with puma
         
     | 
| 
       3 
     | 
    
         
            -
            <% c = Capistrano::BaseHelper::get_capistrano_instance %>
         
     | 
| 
       4 
7 
     | 
    
         
             
            cd '<%= c.current_path %>'
         
     | 
| 
       5 
8 
     | 
    
         
             
            RAILS_ENV=<%= Capistrano::BaseHelper.environment %> exec <%= c.fetch(:puma_control) %> -S <%= c.fetch(:puma_state_file) %> stop
         
     | 
| 
         @@ -0,0 +1,135 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/bin/bash
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # This finish file is originally from:
         
     | 
| 
      
 4 
     | 
    
         
            +
            # https://github.com/erwbgy/puppet-runit/blob/fde6006e6d400f0c99b6ff0b1b63094207dc8783/templates/service/finish.erb
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Thanks to erwbgy!
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # <% c = Capistrano::BaseHelper.get_capistrano_instance %>
         
     | 
| 
      
 8 
     | 
    
         
            +
            # Variable name setup
         
     | 
| 
      
 9 
     | 
    
         
            +
            <%
         
     | 
| 
      
 10 
     | 
    
         
            +
            exit_code   = "EXIT_CODE_#{Capistrano::BaseHelper.user_app_env_underscore_short}_#{c.fetch(:puma_runit_service_name)}".upcase
         
     | 
| 
      
 11 
     | 
    
         
            +
            exit_status = "EXIT_STATUS_#{Capistrano::BaseHelper.user_app_env_underscore_short}_#{c.fetch(:puma_runit_service_name)}".upcase
         
     | 
| 
      
 12 
     | 
    
         
            +
            min_auto_restart_interval         = "MIN_AUTO_RESTART_INTERVAL_#{Capistrano::BaseHelper.user_app_env_underscore_short}_#{c.fetch(:puma_runit_service_name)}".upcase
         
     | 
| 
      
 13 
     | 
    
         
            +
            max_auto_restart_count            = "MAX_AUTO_RESTART_COUNT_#{Capistrano::BaseHelper.user_app_env_underscore_short}_#{c.fetch(:puma_runit_service_name)}".upcase
         
     | 
| 
      
 14 
     | 
    
         
            +
            auto_restart_count_clear_interval = "AUTO_RESTART_COUNT_CLEAR_INTERVAL_#{Capistrano::BaseHelper.user_app_env_underscore_short}_#{c.fetch(:puma_runit_service_name)}".upcase
         
     | 
| 
      
 15 
     | 
    
         
            +
            %>
         
     | 
| 
      
 16 
     | 
    
         
            +
            #
         
     | 
| 
      
 17 
     | 
    
         
            +
            # The following variables are set by Runit:
         
     | 
| 
      
 18 
     | 
    
         
            +
            #
         
     | 
| 
      
 19 
     | 
    
         
            +
            # <%= "#{exit_code}" %>: ./run's exit code
         
     | 
| 
      
 20 
     | 
    
         
            +
            #
         
     | 
| 
      
 21 
     | 
    
         
            +
            # <%= "#{exit_status}" %>: The least significant byte of the exit status as determined by
         
     | 
| 
      
 22 
     | 
    
         
            +
            #  waitpid(2); for instance it is 0 if ./run exited normally, and the signal
         
     | 
| 
      
 23 
     | 
    
         
            +
            #  number if ./run was terminated by a signal.
         
     | 
| 
      
 24 
     | 
    
         
            +
            #
         
     | 
| 
      
 25 
     | 
    
         
            +
            # The following configuration variables must be set:
         
     | 
| 
      
 26 
     | 
    
         
            +
            #
         
     | 
| 
      
 27 
     | 
    
         
            +
            # <%= "#{min_auto_restart_interval}" %>: The minimum delay (in seconds) between automatic restarts
         
     | 
| 
      
 28 
     | 
    
         
            +
            #
         
     | 
| 
      
 29 
     | 
    
         
            +
            # <%= "#{max_auto_restart_count}" %>: The maximum number of automatic restarts allowed
         
     | 
| 
      
 30 
     | 
    
         
            +
            #
         
     | 
| 
      
 31 
     | 
    
         
            +
            # <%= "#{auto_restart_count_clear_interval}" %>: Reset the restart count if
         
     | 
| 
      
 32 
     | 
    
         
            +
            #  <%= "#{auto_restart_count_clear_interval}" %> seconds have elapsed since the last
         
     | 
| 
      
 33 
     | 
    
         
            +
            #  automatic restart.
         
     | 
| 
      
 34 
     | 
    
         
            +
            #
         
     | 
| 
      
 35 
     | 
    
         
            +
            # Creates two new files in the service directory:
         
     | 
| 
      
 36 
     | 
    
         
            +
            #
         
     | 
| 
      
 37 
     | 
    
         
            +
            #   last_finish - the Unix time (seconds since 1970) when the ./finish script
         
     | 
| 
      
 38 
     | 
    
         
            +
            #                 last ran
         
     | 
| 
      
 39 
     | 
    
         
            +
            #
         
     | 
| 
      
 40 
     | 
    
         
            +
            #   restart_count - the number of automatic restarts that have taken place
         
     | 
| 
      
 41 
     | 
    
         
            +
            #
         
     | 
| 
      
 42 
     | 
    
         
            +
            # These files must be removed BEFORE the service is cleanly shut down.
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            ### Configuration
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            # ./run's exit code
         
     | 
| 
      
 47 
     | 
    
         
            +
            <%= "#{exit_code}" %>=$1
         
     | 
| 
      
 48 
     | 
    
         
            +
             
         
     | 
| 
      
 49 
     | 
    
         
            +
            # The least significant byte of the exit status as determined by waitpid(2);
         
     | 
| 
      
 50 
     | 
    
         
            +
            # for instance it is 0 if ./run exited normally, and the signal number if
         
     | 
| 
      
 51 
     | 
    
         
            +
            # ./run was terminated by a signal.
         
     | 
| 
      
 52 
     | 
    
         
            +
            <%= "#{exit_status}" %>=$2
         
     | 
| 
      
 53 
     | 
    
         
            +
             
         
     | 
| 
      
 54 
     | 
    
         
            +
            # The minimum delay (in seconds) between automatic restarts
         
     | 
| 
      
 55 
     | 
    
         
            +
            <%= "#{min_auto_restart_interval}" %>=<%= c.fetch(:puma_restart_interval) %>
         
     | 
| 
      
 56 
     | 
    
         
            +
             
         
     | 
| 
      
 57 
     | 
    
         
            +
            # The maximum number of automatic restarts allowed
         
     | 
| 
      
 58 
     | 
    
         
            +
            <%= "#{max_auto_restart_count}" %>=<%= c.fetch(:puma_restart_count) %>
         
     | 
| 
      
 59 
     | 
    
         
            +
             
         
     | 
| 
      
 60 
     | 
    
         
            +
            # Reset the restart count if <%= "#{auto_restart_count_clear_interval}" %> seconds
         
     | 
| 
      
 61 
     | 
    
         
            +
            # have elapsed since the last automatic restart.
         
     | 
| 
      
 62 
     | 
    
         
            +
            <%= "#{auto_restart_count_clear_interval}" %>=<%= c.fetch(:puma_autorestart_clear_interval) %>
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            export <%= "#{exit_code}" %>
         
     | 
| 
      
 65 
     | 
    
         
            +
            export <%= "#{exit_status}" %>
         
     | 
| 
      
 66 
     | 
    
         
            +
            export <%= "#{min_auto_restart_interval}" %>
         
     | 
| 
      
 67 
     | 
    
         
            +
            export <%= "#{max_auto_restart_count}" %>
         
     | 
| 
      
 68 
     | 
    
         
            +
            export <%= "#{auto_restart_count_clear_interval }" %>
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            ### Normally no changes should be made after this point
         
     | 
| 
      
 71 
     | 
    
         
            +
             
         
     | 
| 
      
 72 
     | 
    
         
            +
            echo "<%= "User: #{c.fetch(:user)} Application: #{c.fetch(:application)} Service: #{c.fetch(:puma_runit_service_name)}" %> finish; exit code: $<%= "#{exit_code}" %>; exit status: $<%= "#{exit_status}" %>"
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            if test $<%= "#{exit_code}" %> -eq 0 -a $<%= "#{exit_status}" %> -eq 0
         
     | 
| 
      
 75 
     | 
    
         
            +
            then
         
     | 
| 
      
 76 
     | 
    
         
            +
                echo "Clean shutdown."
         
     | 
| 
      
 77 
     | 
    
         
            +
                sv down .
         
     | 
| 
      
 78 
     | 
    
         
            +
                exit 0
         
     | 
| 
      
 79 
     | 
    
         
            +
            fi
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            NOW=$(date +%s)
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            # Determine when the finish script last ran
         
     | 
| 
      
 84 
     | 
    
         
            +
            if test -r last_finish
         
     | 
| 
      
 85 
     | 
    
         
            +
            then
         
     | 
| 
      
 86 
     | 
    
         
            +
                LAST_FINISH=$(head -1 last_finish)
         
     | 
| 
      
 87 
     | 
    
         
            +
                INTERVAL=$(expr $NOW - $LAST_FINISH)
         
     | 
| 
      
 88 
     | 
    
         
            +
            fi
         
     | 
| 
      
 89 
     | 
    
         
            +
            echo $NOW > last_finish
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            # Remove the restart_count file if <%= "#{auto_restart_count_clear_interval}" %> seconds
         
     | 
| 
      
 92 
     | 
    
         
            +
            # have elapsed since the last automatic restart.
         
     | 
| 
      
 93 
     | 
    
         
            +
            if test $INTERVAL -gt $<%= "#{auto_restart_count_clear_interval}" %>
         
     | 
| 
      
 94 
     | 
    
         
            +
            then
         
     | 
| 
      
 95 
     | 
    
         
            +
                echo "NOTICE: <%= "User: #{c.fetch(:user)} Application: #{c.fetch(:application)} Service: #{c.fetch(:puma_runit_service_name)}" %>"
         
     | 
| 
      
 96 
     | 
    
         
            +
                echo "The last automatic restart was $INTERVAL seconds ago."
         
     | 
| 
      
 97 
     | 
    
         
            +
                echo "Since this is greater than $<%= "#{auto_restart_count_clear_interval}" %> the restart count is being reset."
         
     | 
| 
      
 98 
     | 
    
         
            +
                rm -f restart_count
         
     | 
| 
      
 99 
     | 
    
         
            +
            fi
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            # Determine how many automatic restarts we have had
         
     | 
| 
      
 102 
     | 
    
         
            +
            # and then increment this value by one
         
     | 
| 
      
 103 
     | 
    
         
            +
            if test -r restart_count
         
     | 
| 
      
 104 
     | 
    
         
            +
            then
         
     | 
| 
      
 105 
     | 
    
         
            +
                RESTART_COUNT=$(head -1 restart_count)
         
     | 
| 
      
 106 
     | 
    
         
            +
                RESTART_COUNT=$(expr $RESTART_COUNT + 1)
         
     | 
| 
      
 107 
     | 
    
         
            +
            else
         
     | 
| 
      
 108 
     | 
    
         
            +
                RESTART_COUNT=1
         
     | 
| 
      
 109 
     | 
    
         
            +
            fi
         
     | 
| 
      
 110 
     | 
    
         
            +
            echo $RESTART_COUNT > restart_count
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
            # Check that we have not exceeded the maximum number of automatic restarts
         
     | 
| 
      
 113 
     | 
    
         
            +
            if test $RESTART_COUNT -gt $<%= "#{max_auto_restart_count}" %>
         
     | 
| 
      
 114 
     | 
    
         
            +
            then
         
     | 
| 
      
 115 
     | 
    
         
            +
                echo "WARNING: <%= "User: #{c.fetch(:user)} Application: #{c.fetch(:application)} Service: #{c.fetch(:puma_runit_service_name)}" %>"
         
     | 
| 
      
 116 
     | 
    
         
            +
                echo "Reached the limit of $<%= "#{max_auto_restart_count}" %> automatic restarts."
         
     | 
| 
      
 117 
     | 
    
         
            +
                echo "The last automatic restart was within $<%= "#{auto_restart_count_clear_interval}" %> seconds."
         
     | 
| 
      
 118 
     | 
    
         
            +
                echo "Manual intervention required.  No further automatic restarts will be attempted."
         
     | 
| 
      
 119 
     | 
    
         
            +
                sv down .
         
     | 
| 
      
 120 
     | 
    
         
            +
                exit 0
         
     | 
| 
      
 121 
     | 
    
         
            +
            fi
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
            if test -n "$INTERVAL"
         
     | 
| 
      
 124 
     | 
    
         
            +
            then
         
     | 
| 
      
 125 
     | 
    
         
            +
                SLEEP_TIME=$(expr $<%= "#{min_auto_restart_interval}" %> - $INTERVAL)
         
     | 
| 
      
 126 
     | 
    
         
            +
                if test $SLEEP_TIME -gt 0
         
     | 
| 
      
 127 
     | 
    
         
            +
                then
         
     | 
| 
      
 128 
     | 
    
         
            +
                    echo "NOTICE: Restart attempt $RESTART_COUNT for <%= "User: #{c.fetch(:user)} Application: #{c.fetch(:application)} Service: #{c.fetch(:puma_runit_service_name)}" %>"
         
     | 
| 
      
 129 
     | 
    
         
            +
                    echo "$INTERVAL seconds have elapsed since the last automatic restart."
         
     | 
| 
      
 130 
     | 
    
         
            +
                    echo "Sleeping for $SLEEP_TIME seconds before the next automatic restart ..."
         
     | 
| 
      
 131 
     | 
    
         
            +
                    sleep $SLEEP_TIME
         
     | 
| 
      
 132 
     | 
    
         
            +
                fi
         
     | 
| 
      
 133 
     | 
    
         
            +
            fi
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            exit 0
         
     | 
    
        data/templates/runit/run.erb
    CHANGED
    
    | 
         @@ -1,9 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            #!/bin/bash --login
         
     | 
| 
       2 
2 
     | 
    
         
             
            # Start puma service
         
     | 
| 
       3 
     | 
    
         
            -
            <% c = Capistrano::BaseHelper 
     | 
| 
      
 3 
     | 
    
         
            +
            # <% c = Capistrano::BaseHelper.get_capistrano_instance %>
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # Redirect stderr so everything ends up in the log file
         
     | 
| 
      
 6 
     | 
    
         
            +
            exec 2>&1
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            # Announce start
         
     | 
| 
      
 9 
     | 
    
         
            +
            echo "<%= "User: #{c.fetch(:user)} Application: #{c.fetch(:application)} Service: #{c.fetch(:puma_runit_service_name)}" %> starting..."
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       4 
11 
     | 
    
         
             
            # remove pumactl.sock and puma.sock if existing, as puma doesn't overwrite and files may be 
         
     | 
| 
       5 
12 
     | 
    
         
             
            # existing after server crash or if puma wasnt shutdown properly.
         
     | 
| 
       6 
13 
     | 
    
         
             
            rm -f "<%= c.fetch(:puma_socket_file) %>"
         
     | 
| 
       7 
14 
     | 
    
         
             
            rm -f "<%= c.fetch(:puma_control_file) %>"
         
     | 
| 
       8 
15 
     | 
    
         
             
            cd '<%= c.current_path %>'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            # Start puma
         
     | 
| 
       9 
18 
     | 
    
         
             
            RAILS_ENV=<%= Capistrano::BaseHelper.environment %> exec <%= c.fetch(:puma_bin) %> -C <%= c.fetch(:puma_remote_config) %>
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: capistrano-pumaio
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.5
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2013-07- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2013-07-08 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: capistrano
         
     | 
| 
         @@ -34,7 +34,7 @@ dependencies: 
     | 
|
| 
       34 
34 
     | 
    
         
             
                requirements:
         
     | 
| 
       35 
35 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
       36 
36 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       37 
     | 
    
         
            -
                    version: 0.0. 
     | 
| 
      
 37 
     | 
    
         
            +
                    version: 0.0.6
         
     | 
| 
       38 
38 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       39 
39 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       40 
40 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -42,7 +42,7 @@ dependencies: 
     | 
|
| 
       42 
42 
     | 
    
         
             
                requirements:
         
     | 
| 
       43 
43 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
       44 
44 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       45 
     | 
    
         
            -
                    version: 0.0. 
     | 
| 
      
 45 
     | 
    
         
            +
                    version: 0.0.6
         
     | 
| 
       46 
46 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       47 
47 
     | 
    
         
             
              name: bundler
         
     | 
| 
       48 
48 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -97,6 +97,7 @@ files: 
     | 
|
| 
       97 
97 
     | 
    
         
             
            - templates/monit/puma.conf.erb
         
     | 
| 
       98 
98 
     | 
    
         
             
            - templates/runit/config.rb.erb
         
     | 
| 
       99 
99 
     | 
    
         
             
            - templates/runit/control-q.erb
         
     | 
| 
      
 100 
     | 
    
         
            +
            - templates/runit/finish.erb
         
     | 
| 
       100 
101 
     | 
    
         
             
            - templates/runit/log-run.erb
         
     | 
| 
       101 
102 
     | 
    
         
             
            - templates/runit/run.erb
         
     | 
| 
       102 
103 
     | 
    
         
             
            homepage: https://github.com/leifcr/capistrano-puma
         
     | 
| 
         @@ -114,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       114 
115 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       115 
116 
     | 
    
         
             
                  segments:
         
     | 
| 
       116 
117 
     | 
    
         
             
                  - 0
         
     | 
| 
       117 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 118 
     | 
    
         
            +
                  hash: -4210930793118983837
         
     | 
| 
       118 
119 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       119 
120 
     | 
    
         
             
              none: false
         
     | 
| 
       120 
121 
     | 
    
         
             
              requirements:
         
     |