capistrano-sidekiq 2.2.0 → 3.0.0.alpha.1
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.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +23 -2
 - data/README.md +6 -66
 - data/lib/capistrano/sidekiq/systemd.rb +38 -9
 - data/lib/capistrano/sidekiq/version.rb +3 -1
 - data/lib/capistrano/sidekiq.rb +56 -8
 - data/lib/capistrano/tasks/systemd.rake +72 -219
 - data/lib/capistrano/templates/sidekiq.service.capistrano.erb +45 -0
 - data/lib/generators/capistrano/sidekiq/monit/templates/sidekiq_monit.conf.erb +7 -5
 - metadata +13 -25
 - data/.gitignore +0 -19
 - data/.tool-versions +0 -1
 - data/CONTRIBUTORS.md +0 -11
 - data/Gemfile +0 -8
 - data/Rakefile +0 -9
 - data/capistrano-sidekiq.gemspec +0 -22
 - data/lib/capistrano/sidekiq/helpers.rb +0 -60
 - data/lib/capistrano/sidekiq/monit.rb +0 -19
 - data/lib/capistrano/sidekiq/upstart.rb +0 -15
 - data/lib/capistrano/tasks/monit.rake +0 -127
 - data/lib/capistrano/tasks/upstart.rake +0 -104
 - data/lib/generators/capistrano/sidekiq/systemd/templates/sidekiq.service.capistrano.erb +0 -70
 - data/lib/generators/capistrano/sidekiq/upstart/templates/sidekiq.conf.erb +0 -78
 - data/lib/generators/capistrano/sidekiq/upstart/templates/workers.conf.erb +0 -37
 
| 
         @@ -0,0 +1,45 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Source: https://github.com/mperham/sidekiq/blob/master/examples/systemd/sidekiq.service
         
     | 
| 
      
 2 
     | 
    
         
            +
            #
         
     | 
| 
      
 3 
     | 
    
         
            +
            # This file tells systemd how to run Sidekiq as a 24/7 long-running daemon.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # Then run:
         
     | 
| 
      
 6 
     | 
    
         
            +
            #   - systemctl enable <%= sidekiq_service_unit_name(@config_file) %>
         
     | 
| 
      
 7 
     | 
    
         
            +
            #   - systemctl {start,stop,restart} <%= sidekiq_service_unit_name(@config_file) %>
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # Use `journalctl -u <%= sidekiq_service_unit_name(@config_file) %> -rn 100` to view the last 100 lines of log output.
         
     | 
| 
      
 10 
     | 
    
         
            +
            #
         
     | 
| 
      
 11 
     | 
    
         
            +
            [Unit]
         
     | 
| 
      
 12 
     | 
    
         
            +
            Description=Sidekiq for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
         
     | 
| 
      
 13 
     | 
    
         
            +
            # start us only once the network and logging subsystems are available,
         
     | 
| 
      
 14 
     | 
    
         
            +
            # consider adding redis-server.service if Redis is local and systemd-managed.
         
     | 
| 
      
 15 
     | 
    
         
            +
            After=syslog.target network.target
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            [Service]
         
     | 
| 
      
 18 
     | 
    
         
            +
            Type=notify
         
     | 
| 
      
 19 
     | 
    
         
            +
            # If your Sidekiq process locks up, systemd's watchdog will restart it within seconds.
         
     | 
| 
      
 20 
     | 
    
         
            +
            WatchdogSec=10
         
     | 
| 
      
 21 
     | 
    
         
            +
            <%="User=#{sidekiq_user}" if fetch(:sidekiq_systemctl_user) == :system %>
         
     | 
| 
      
 22 
     | 
    
         
            +
            WorkingDirectory=<%= current_path %>
         
     | 
| 
      
 23 
     | 
    
         
            +
            ExecStart=<%= expanded_bundle_path %> exec sidekiq -e <%= fetch(:sidekiq_env) %> <%= sidekiq_config %>
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            # Use `systemctl kill -s TSTP <% sidekiq_service_unit_name(@config_file) %>` to quiet the Sidekiq process
         
     | 
| 
      
 26 
     | 
    
         
            +
            UMask=0002
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            <%- Array(fetch(:sidekiq_service_unit_env_files)).each do |file| %>
         
     | 
| 
      
 29 
     | 
    
         
            +
            <%="EnvironmentFile=#{file}" %>
         
     | 
| 
      
 30 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 31 
     | 
    
         
            +
            <% Array(fetch(:sidekiq_service_unit_env_vars)).each do |environment_variable| %>
         
     | 
| 
      
 32 
     | 
    
         
            +
            <%="Environment=\"#{environment_variable}\"" %>
         
     | 
| 
      
 33 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            # if we crash, restart
         
     | 
| 
      
 36 
     | 
    
         
            +
            RestartSec=1
         
     | 
| 
      
 37 
     | 
    
         
            +
            Restart=on-failure
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            <%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) -%>
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            <%="StandardError=append:#{fetch(:sidekiq_error_log)}" if fetch(:sidekiq_error_log) -%>
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            SyslogIdentifier=<%= sidekiq_service_unit_name(@config_file) %>
         
     | 
| 
      
 44 
     | 
    
         
            +
            [Install]
         
     | 
| 
      
 45 
     | 
    
         
            +
            WantedBy=<%=(fetch(:sidekiq_systemctl_user) == :system) ? "multi-user.target" : "default.target"%>
         
     | 
| 
         @@ -1,6 +1,8 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Monit configuration for Sidekiq 
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
      
 1 
     | 
    
         
            +
            # Monit configuration for Sidekiq
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Service name: <%= sidekiq_service_name %>
         
     | 
| 
      
 3 
     | 
    
         
            +
            #
         
     | 
| 
      
 4 
     | 
    
         
            +
            check process <%= sidekiq_service_name %>
         
     | 
| 
      
 5 
     | 
    
         
            +
              matching 'sidekiq .* <%= fetch(:application) %>'
         
     | 
| 
      
 6 
     | 
    
         
            +
              start program = "/bin/su - <%= sidekiq_user(role) %> -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec sidekiq -e <%= fetch(:sidekiq_env) %> <%= sidekiq_config %> <%= sidekiq_concurrency %> <%= sidekiq_require %> <%= sidekiq_queues %> <%= sidekiq_logfile ? ">> #{sidekiq_logfile} 2>&1" : nil %> &'" with timeout <%= fetch(:sidekiq_timeout).to_i + 10 %> seconds
         
     | 
| 
      
 7 
     | 
    
         
            +
              stop program = "/bin/su - <%= sidekiq_user(role) %> -c 'ps ax | grep "<%= "sidekiq .* #{fetch(:application)}" %>" | grep -v grep | awk "{print \$1}" | xargs --no-run-if-empty kill'" with timeout <%= fetch(:sidekiq_timeout).to_i + 10  %> seconds
         
     | 
| 
       6 
8 
     | 
    
         
             
              group <%= fetch(:sidekiq_monit_group) || fetch(:application) %>-sidekiq
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: capistrano-sidekiq
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.0.0.alpha.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Abdelkader Boudih
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire:
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-10-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: capistrano
         
     | 
| 
         @@ -44,14 +44,14 @@ dependencies: 
     | 
|
| 
       44 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       45 
45 
     | 
    
         
             
                - - ">="
         
     | 
| 
       46 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       47 
     | 
    
         
            -
                    version:  
     | 
| 
      
 47 
     | 
    
         
            +
                    version: 6.0.6
         
     | 
| 
       48 
48 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       49 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       50 
50 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
51 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
52 
     | 
    
         
             
                - - ">="
         
     | 
| 
       53 
53 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
     | 
    
         
            -
                    version:  
     | 
| 
      
 54 
     | 
    
         
            +
                    version: 6.0.6
         
     | 
| 
       55 
55 
     | 
    
         
             
            description: Sidekiq integration for Capistrano
         
     | 
| 
       56 
56 
     | 
    
         
             
            email:
         
     | 
| 
       57 
57 
     | 
    
         
             
            - terminale@gmail.com
         
     | 
| 
         @@ -59,36 +59,24 @@ executables: [] 
     | 
|
| 
       59 
59 
     | 
    
         
             
            extensions: []
         
     | 
| 
       60 
60 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       61 
61 
     | 
    
         
             
            files:
         
     | 
| 
       62 
     | 
    
         
            -
            - ".gitignore"
         
     | 
| 
       63 
     | 
    
         
            -
            - ".tool-versions"
         
     | 
| 
       64 
62 
     | 
    
         
             
            - CHANGELOG.md
         
     | 
| 
       65 
     | 
    
         
            -
            - CONTRIBUTORS.md
         
     | 
| 
       66 
     | 
    
         
            -
            - Gemfile
         
     | 
| 
       67 
63 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       68 
64 
     | 
    
         
             
            - README.md
         
     | 
| 
       69 
     | 
    
         
            -
            - Rakefile
         
     | 
| 
       70 
     | 
    
         
            -
            - capistrano-sidekiq.gemspec
         
     | 
| 
       71 
65 
     | 
    
         
             
            - lib/capistrano-sidekiq.rb
         
     | 
| 
       72 
66 
     | 
    
         
             
            - lib/capistrano/sidekiq.rb
         
     | 
| 
       73 
     | 
    
         
            -
            - lib/capistrano/sidekiq/helpers.rb
         
     | 
| 
       74 
     | 
    
         
            -
            - lib/capistrano/sidekiq/monit.rb
         
     | 
| 
       75 
67 
     | 
    
         
             
            - lib/capistrano/sidekiq/systemd.rb
         
     | 
| 
       76 
     | 
    
         
            -
            - lib/capistrano/sidekiq/upstart.rb
         
     | 
| 
       77 
68 
     | 
    
         
             
            - lib/capistrano/sidekiq/version.rb
         
     | 
| 
       78 
     | 
    
         
            -
            - lib/capistrano/tasks/monit.rake
         
     | 
| 
       79 
69 
     | 
    
         
             
            - lib/capistrano/tasks/sidekiq.rake
         
     | 
| 
       80 
70 
     | 
    
         
             
            - lib/capistrano/tasks/systemd.rake
         
     | 
| 
       81 
     | 
    
         
            -
            - lib/capistrano/ 
     | 
| 
      
 71 
     | 
    
         
            +
            - lib/capistrano/templates/sidekiq.service.capistrano.erb
         
     | 
| 
       82 
72 
     | 
    
         
             
            - lib/generators/capistrano/sidekiq/monit/template_generator.rb
         
     | 
| 
       83 
73 
     | 
    
         
             
            - lib/generators/capistrano/sidekiq/monit/templates/sidekiq_monit.conf.erb
         
     | 
| 
       84 
     | 
    
         
            -
            - lib/generators/capistrano/sidekiq/systemd/templates/sidekiq.service.capistrano.erb
         
     | 
| 
       85 
     | 
    
         
            -
            - lib/generators/capistrano/sidekiq/upstart/templates/sidekiq.conf.erb
         
     | 
| 
       86 
     | 
    
         
            -
            - lib/generators/capistrano/sidekiq/upstart/templates/workers.conf.erb
         
     | 
| 
       87 
74 
     | 
    
         
             
            homepage: https://github.com/seuros/capistrano-sidekiq
         
     | 
| 
       88 
75 
     | 
    
         
             
            licenses:
         
     | 
| 
       89 
76 
     | 
    
         
             
            - LGPL-3.0
         
     | 
| 
       90 
77 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       91 
     | 
    
         
            -
            post_install_message:
         
     | 
| 
      
 78 
     | 
    
         
            +
            post_install_message: "\n    Version 3.0.0 is a major release. Please see README.md,
         
     | 
| 
      
 79 
     | 
    
         
            +
              breaking changes are listed in CHANGELOG.md\n  "
         
     | 
| 
       92 
80 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       93 
81 
     | 
    
         
             
            require_paths:
         
     | 
| 
       94 
82 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -96,15 +84,15 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       96 
84 
     | 
    
         
             
              requirements:
         
     | 
| 
       97 
85 
     | 
    
         
             
              - - ">="
         
     | 
| 
       98 
86 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       99 
     | 
    
         
            -
                  version: 2. 
     | 
| 
      
 87 
     | 
    
         
            +
                  version: 2.5.0
         
     | 
| 
       100 
88 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       101 
89 
     | 
    
         
             
              requirements:
         
     | 
| 
       102 
     | 
    
         
            -
              - - " 
     | 
| 
      
 90 
     | 
    
         
            +
              - - ">"
         
     | 
| 
       103 
91 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       104 
     | 
    
         
            -
                  version:  
     | 
| 
      
 92 
     | 
    
         
            +
                  version: 1.3.1
         
     | 
| 
       105 
93 
     | 
    
         
             
            requirements: []
         
     | 
| 
       106 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       107 
     | 
    
         
            -
            signing_key:
         
     | 
| 
      
 94 
     | 
    
         
            +
            rubygems_version: 3.1.6
         
     | 
| 
      
 95 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
       108 
96 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       109 
97 
     | 
    
         
             
            summary: Sidekiq integration for Capistrano
         
     | 
| 
       110 
98 
     | 
    
         
             
            test_files: []
         
     | 
    
        data/.gitignore
    DELETED
    
    
    
        data/.tool-versions
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ruby 3.1.2
         
     | 
    
        data/CONTRIBUTORS.md
    DELETED
    
    | 
         @@ -1,11 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ## Contributors
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            - [Jérémy Lecour] (https://github.com/jlecour)
         
     | 
| 
       4 
     | 
    
         
            -
            - [Fabien Penso] (https://github.com/penso)
         
     | 
| 
       5 
     | 
    
         
            -
            - [Alex Dunae] (https://github.com/alexdunae)
         
     | 
| 
       6 
     | 
    
         
            -
            - [andreygerasimchuk] (https://github.com/andreygerasimchuk)
         
     | 
| 
       7 
     | 
    
         
            -
            - [Saicheg] (https://github.com/Saicheg)
         
     | 
| 
       8 
     | 
    
         
            -
            - [Alex Yakubenko] (https://github.com/alexyakubenko)
         
     | 
| 
       9 
     | 
    
         
            -
            - [Robert Strobl] (https://github.com/rstrobl)
         
     | 
| 
       10 
     | 
    
         
            -
            - [Eurico Doirado] (https://github.com/okoriko)
         
     | 
| 
       11 
     | 
    
         
            -
            - [Huang Bin](https://github.com/hbin)
         
     | 
    
        data/Gemfile
    DELETED
    
    
    
        data/Rakefile
    DELETED
    
    | 
         @@ -1,9 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "bundler/gem_tasks"
         
     | 
| 
       2 
     | 
    
         
            -
            require 'github_changelog_generator/task'
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            GitHubChangelogGenerator::RakeTask.new :changelog do |config|
         
     | 
| 
       5 
     | 
    
         
            -
              config.user = 'seuros'
         
     | 
| 
       6 
     | 
    
         
            -
              config.project = 'capistrano-sidekiq'
         
     | 
| 
       7 
     | 
    
         
            -
              config.issues = false
         
     | 
| 
       8 
     | 
    
         
            -
              config.future_release = '2.2.0'
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
    
        data/capistrano-sidekiq.gemspec
    DELETED
    
    | 
         @@ -1,22 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
       2 
     | 
    
         
            -
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
       3 
     | 
    
         
            -
            require 'capistrano/sidekiq/version'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            Gem::Specification.new do |spec|
         
     | 
| 
       6 
     | 
    
         
            -
              spec.name = 'capistrano-sidekiq'
         
     | 
| 
       7 
     | 
    
         
            -
              spec.version = Capistrano::SidekiqVERSION
         
     | 
| 
       8 
     | 
    
         
            -
              spec.authors = ['Abdelkader Boudih']
         
     | 
| 
       9 
     | 
    
         
            -
              spec.email = ['terminale@gmail.com']
         
     | 
| 
       10 
     | 
    
         
            -
              spec.summary = %q{Sidekiq integration for Capistrano}
         
     | 
| 
       11 
     | 
    
         
            -
              spec.description = %q{Sidekiq integration for Capistrano}
         
     | 
| 
       12 
     | 
    
         
            -
              spec.homepage = 'https://github.com/seuros/capistrano-sidekiq'
         
     | 
| 
       13 
     | 
    
         
            -
              spec.license = 'LGPL-3.0'
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              spec.required_ruby_version     = '>= 2.0.0'
         
     | 
| 
       16 
     | 
    
         
            -
              spec.files = `git ls-files`.split($/)
         
     | 
| 
       17 
     | 
    
         
            -
              spec.require_paths = ['lib']
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              spec.add_dependency 'capistrano', '>= 3.9.0'
         
     | 
| 
       20 
     | 
    
         
            -
              spec.add_dependency 'capistrano-bundler'
         
     | 
| 
       21 
     | 
    
         
            -
              spec.add_dependency 'sidekiq', '>= 6.0'
         
     | 
| 
       22 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,60 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Capistrano
         
     | 
| 
       2 
     | 
    
         
            -
              module Sidekiq::Helpers
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
                def sidekiq_require
         
     | 
| 
       5 
     | 
    
         
            -
                  if fetch(:sidekiq_require)
         
     | 
| 
       6 
     | 
    
         
            -
                    "--require #{fetch(:sidekiq_require)}"
         
     | 
| 
       7 
     | 
    
         
            -
                  end
         
     | 
| 
       8 
     | 
    
         
            -
                end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                def sidekiq_config
         
     | 
| 
       11 
     | 
    
         
            -
                  if fetch(:sidekiq_config)
         
     | 
| 
       12 
     | 
    
         
            -
                    "--config #{fetch(:sidekiq_config)}"
         
     | 
| 
       13 
     | 
    
         
            -
                  end
         
     | 
| 
       14 
     | 
    
         
            -
                end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                def sidekiq_concurrency
         
     | 
| 
       17 
     | 
    
         
            -
                  if fetch(:sidekiq_concurrency)
         
     | 
| 
       18 
     | 
    
         
            -
                    "--concurrency #{fetch(:sidekiq_concurrency)}"
         
     | 
| 
       19 
     | 
    
         
            -
                  end
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                def sidekiq_queues
         
     | 
| 
       23 
     | 
    
         
            -
                  Array(fetch(:sidekiq_queue)).map do |queue|
         
     | 
| 
       24 
     | 
    
         
            -
                    "--queue #{queue}"
         
     | 
| 
       25 
     | 
    
         
            -
                  end.join(' ')
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                def sidekiq_logfile
         
     | 
| 
       29 
     | 
    
         
            -
                  fetch(:sidekiq_log)
         
     | 
| 
       30 
     | 
    
         
            -
                end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                def switch_user(role)
         
     | 
| 
       33 
     | 
    
         
            -
                  su_user = sidekiq_user(role)
         
     | 
| 
       34 
     | 
    
         
            -
                  if su_user == role.user
         
     | 
| 
       35 
     | 
    
         
            -
                    yield
         
     | 
| 
       36 
     | 
    
         
            -
                  else
         
     | 
| 
       37 
     | 
    
         
            -
                    as su_user do
         
     | 
| 
       38 
     | 
    
         
            -
                      yield
         
     | 
| 
       39 
     | 
    
         
            -
                    end
         
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
       41 
     | 
    
         
            -
                end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                def sidekiq_user(role = nil)
         
     | 
| 
       44 
     | 
    
         
            -
                  if role.nil?
         
     | 
| 
       45 
     | 
    
         
            -
                    fetch(:sidekiq_user)
         
     | 
| 
       46 
     | 
    
         
            -
                  else
         
     | 
| 
       47 
     | 
    
         
            -
                    properties = role.properties
         
     | 
| 
       48 
     | 
    
         
            -
                    properties.fetch(:sidekiq_user) || # local property for sidekiq only
         
     | 
| 
       49 
     | 
    
         
            -
                      fetch(:sidekiq_user) ||
         
     | 
| 
       50 
     | 
    
         
            -
                      properties.fetch(:run_as) || # global property across multiple capistrano gems
         
     | 
| 
       51 
     | 
    
         
            -
                      role.user
         
     | 
| 
       52 
     | 
    
         
            -
                  end
         
     | 
| 
       53 
     | 
    
         
            -
                end
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                def expanded_bundle_path
         
     | 
| 
       56 
     | 
    
         
            -
                  backend.capture(:echo, SSHKit.config.command_map[:bundle]).strip
         
     | 
| 
       57 
     | 
    
         
            -
                end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,19 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module Capistrano
         
     | 
| 
       2 
     | 
    
         
            -
              class Sidekiq::Monit < Capistrano::Plugin
         
     | 
| 
       3 
     | 
    
         
            -
                include Sidekiq::Helpers
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
                def set_defaults
         
     | 
| 
       6 
     | 
    
         
            -
                  set_if_empty :monit_bin, '/usr/bin/monit'
         
     | 
| 
       7 
     | 
    
         
            -
                  set_if_empty :sidekiq_monit_conf_dir, '/etc/monit/conf.d'
         
     | 
| 
       8 
     | 
    
         
            -
                  set_if_empty :sidekiq_monit_conf_file, -> { "#{sidekiq_service_name}.conf" }
         
     | 
| 
       9 
     | 
    
         
            -
                  set_if_empty :sidekiq_monit_use_sudo, true
         
     | 
| 
       10 
     | 
    
         
            -
                  set_if_empty :sidekiq_monit_default_hooks, true
         
     | 
| 
       11 
     | 
    
         
            -
                  set_if_empty :sidekiq_monit_templates_path, 'config/deploy/templates'
         
     | 
| 
       12 
     | 
    
         
            -
                  set_if_empty :sidekiq_monit_group, nil
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                def define_tasks
         
     | 
| 
       16 
     | 
    
         
            -
                  eval_rakefile File.expand_path('../../tasks/monit.rake', __FILE__)
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,15 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module Capistrano
         
     | 
| 
       4 
     | 
    
         
            -
              class Sidekiq::Upstart < Capistrano::Plugin
         
     | 
| 
       5 
     | 
    
         
            -
                include Sidekiq::Helpers
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                def set_defaults
         
     | 
| 
       8 
     | 
    
         
            -
                  set_if_empty :sidekiq_service_unit_name, 'sidekiq' # This will change in version 3.0.0 to {application}-sidekiq
         
     | 
| 
       9 
     | 
    
         
            -
                end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                def define_tasks
         
     | 
| 
       12 
     | 
    
         
            -
                  eval_rakefile File.expand_path('../tasks/upstart.rake', __dir__)
         
     | 
| 
       13 
     | 
    
         
            -
                end
         
     | 
| 
       14 
     | 
    
         
            -
              end
         
     | 
| 
       15 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,127 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            git_plugin = self
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            namespace :deploy do
         
     | 
| 
       4 
     | 
    
         
            -
              before :starting, :check_sidekiq_monit_hooks do
         
     | 
| 
       5 
     | 
    
         
            -
                if fetch(:sidekiq_default_hooks) && fetch(:sidekiq_monit_default_hooks)
         
     | 
| 
       6 
     | 
    
         
            -
                  invoke 'sidekiq:monit:add_default_hooks'
         
     | 
| 
       7 
     | 
    
         
            -
                end
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            namespace :sidekiq do
         
     | 
| 
       12 
     | 
    
         
            -
              namespace :monit do
         
     | 
| 
       13 
     | 
    
         
            -
                task :add_default_hooks do
         
     | 
| 
       14 
     | 
    
         
            -
                  before 'deploy:updating',  'sidekiq:monit:unmonitor'
         
     | 
| 
       15 
     | 
    
         
            -
                  after  'deploy:published', 'sidekiq:monit:monitor'
         
     | 
| 
       16 
     | 
    
         
            -
                end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                desc 'Config Sidekiq monit-service'
         
     | 
| 
       19 
     | 
    
         
            -
                task :config do
         
     | 
| 
       20 
     | 
    
         
            -
                  on roles(fetch(:sidekiq_roles)) do |role|
         
     | 
| 
       21 
     | 
    
         
            -
                    @role = role
         
     | 
| 
       22 
     | 
    
         
            -
                    git_plugin.upload_sidekiq_template 'sidekiq_monit', "#{fetch(:tmp_dir)}/monit.conf", @role
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                    git_plugin.switch_user(role) do
         
     | 
| 
       25 
     | 
    
         
            -
                      mv_command = "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{fetch(:sidekiq_monit_conf_file)}"
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                      git_plugin.sudo_if_needed mv_command
         
     | 
| 
       28 
     | 
    
         
            -
                      git_plugin.sudo_if_needed "#{fetch(:monit_bin)} reload"
         
     | 
| 
       29 
     | 
    
         
            -
                    end
         
     | 
| 
       30 
     | 
    
         
            -
                  end
         
     | 
| 
       31 
     | 
    
         
            -
                end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                desc 'Monitor Sidekiq monit-service'
         
     | 
| 
       34 
     | 
    
         
            -
                task :monitor do
         
     | 
| 
       35 
     | 
    
         
            -
                  on roles(fetch(:sidekiq_roles)) do |role|
         
     | 
| 
       36 
     | 
    
         
            -
                    git_plugin.switch_user(role) do
         
     | 
| 
       37 
     | 
    
         
            -
                      begin
         
     | 
| 
       38 
     | 
    
         
            -
                        git_plugin.sudo_if_needed "#{fetch(:monit_bin)} monitor #{git_plugin.sidekiq_service_name}"
         
     | 
| 
       39 
     | 
    
         
            -
                      rescue
         
     | 
| 
       40 
     | 
    
         
            -
                        invoke 'sidekiq:monit:config'
         
     | 
| 
       41 
     | 
    
         
            -
                        git_plugin.sudo_if_needed "#{fetch(:monit_bin)} monitor #{git_plugin.sidekiq_service_name}"
         
     | 
| 
       42 
     | 
    
         
            -
                      end
         
     | 
| 
       43 
     | 
    
         
            -
                    end
         
     | 
| 
       44 
     | 
    
         
            -
                  end
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                desc 'Unmonitor Sidekiq monit-service'
         
     | 
| 
       48 
     | 
    
         
            -
                task :unmonitor do
         
     | 
| 
       49 
     | 
    
         
            -
                  on roles(fetch(:sidekiq_roles)) do |role|
         
     | 
| 
       50 
     | 
    
         
            -
                    git_plugin.switch_user(role) do
         
     | 
| 
       51 
     | 
    
         
            -
                      begin
         
     | 
| 
       52 
     | 
    
         
            -
                        git_plugin.sudo_if_needed "#{fetch(:monit_bin)} unmonitor #{git_plugin.sidekiq_service_name}"
         
     | 
| 
       53 
     | 
    
         
            -
                      rescue
         
     | 
| 
       54 
     | 
    
         
            -
                        # no worries here
         
     | 
| 
       55 
     | 
    
         
            -
                      end
         
     | 
| 
       56 
     | 
    
         
            -
                    end
         
     | 
| 
       57 
     | 
    
         
            -
                  end
         
     | 
| 
       58 
     | 
    
         
            -
                end
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
              desc 'Start Sidekiq monit-service'
         
     | 
| 
       62 
     | 
    
         
            -
              task :start do
         
     | 
| 
       63 
     | 
    
         
            -
                on roles(fetch(:sidekiq_roles)) do |role|
         
     | 
| 
       64 
     | 
    
         
            -
                  git_plugin.switch_user(role) do
         
     | 
| 
       65 
     | 
    
         
            -
                    git_plugin.sudo_if_needed "#{fetch(:monit_bin)} start #{git_plugin.sidekiq_service_name}"
         
     | 
| 
       66 
     | 
    
         
            -
                  end
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
              end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
              desc 'Stop Sidekiq monit-service'
         
     | 
| 
       71 
     | 
    
         
            -
              task :stop do
         
     | 
| 
       72 
     | 
    
         
            -
                on roles(fetch(:sidekiq_roles)) do |role|
         
     | 
| 
       73 
     | 
    
         
            -
                  git_plugin.switch_user(role) do
         
     | 
| 
       74 
     | 
    
         
            -
                    git_plugin.sudo_if_needed "#{fetch(:monit_bin)} stop #{git_plugin.sidekiq_service_name}"
         
     | 
| 
       75 
     | 
    
         
            -
                  end
         
     | 
| 
       76 
     | 
    
         
            -
                end
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
              desc 'Restart Sidekiq monit-service'
         
     | 
| 
       80 
     | 
    
         
            -
              task :restart do
         
     | 
| 
       81 
     | 
    
         
            -
                on roles(fetch(:sidekiq_roles)) do |role|
         
     | 
| 
       82 
     | 
    
         
            -
                  git_plugin.sudo_if_needed "#{fetch(:monit_bin)} restart #{git_plugin.sidekiq_service_name}"
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
              end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
              def sidekiq_service_name
         
     | 
| 
       87 
     | 
    
         
            -
                fetch(:sidekiq_service_name, "sidekiq_#{fetch(:application)}_#{fetch(:sidekiq_env)}")
         
     | 
| 
       88 
     | 
    
         
            -
              end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
              def sudo_if_needed(command)
         
     | 
| 
       91 
     | 
    
         
            -
                if use_sudo?
         
     | 
| 
       92 
     | 
    
         
            -
                  backend.execute :sudo, command
         
     | 
| 
       93 
     | 
    
         
            -
                else
         
     | 
| 
       94 
     | 
    
         
            -
                  backend.execute command
         
     | 
| 
       95 
     | 
    
         
            -
                end
         
     | 
| 
       96 
     | 
    
         
            -
              end
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
              def use_sudo?
         
     | 
| 
       99 
     | 
    
         
            -
                fetch(:sidekiq_monit_use_sudo)
         
     | 
| 
       100 
     | 
    
         
            -
              end
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
              def upload_sidekiq_template(from, to, role)
         
     | 
| 
       103 
     | 
    
         
            -
                template = sidekiq_template(from, role)
         
     | 
| 
       104 
     | 
    
         
            -
                backend.upload!(StringIO.new(ERB.new(template).result(binding)), to)
         
     | 
| 
       105 
     | 
    
         
            -
              end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
              def sidekiq_template(name, role)
         
     | 
| 
       108 
     | 
    
         
            -
                local_template_directory = fetch(:sidekiq_monit_templates_path)
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
                search_paths = [
         
     | 
| 
       111 
     | 
    
         
            -
                  "#{name}-#{role.hostname}-#{fetch(:stage)}.erb",
         
     | 
| 
       112 
     | 
    
         
            -
                  "#{name}-#{role.hostname}.erb",
         
     | 
| 
       113 
     | 
    
         
            -
                  "#{name}-#{fetch(:stage)}.erb",
         
     | 
| 
       114 
     | 
    
         
            -
                  "#{name}.erb"
         
     | 
| 
       115 
     | 
    
         
            -
                ].map { |filename| File.join(local_template_directory, filename) }
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
                global_search_path = File.expand_path(
         
     | 
| 
       118 
     | 
    
         
            -
                  File.join(*%w[.. .. .. generators capistrano sidekiq monit templates], "#{name}.conf.erb"),
         
     | 
| 
       119 
     | 
    
         
            -
                  __FILE__
         
     | 
| 
       120 
     | 
    
         
            -
                )
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
                search_paths << global_search_path
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
                template_path = search_paths.detect { |path| File.file?(path) }
         
     | 
| 
       125 
     | 
    
         
            -
                File.read(template_path)
         
     | 
| 
       126 
     | 
    
         
            -
              end
         
     | 
| 
       127 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,104 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            git_plugin = self
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            SUPPRESS_FAILURE = %w[|| echo NO_RUNNING_INSTANCE].freeze
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            namespace :sidekiq do
         
     | 
| 
       8 
     | 
    
         
            -
              desc 'Quiet sidekiq (stop fetching new tasks from Redis)'
         
     | 
| 
       9 
     | 
    
         
            -
              task :quiet do
         
     | 
| 
       10 
     | 
    
         
            -
                on roles fetch(:sidekiq_roles) do |role|
         
     | 
| 
       11 
     | 
    
         
            -
                  git_plugin.switch_user(role) do
         
     | 
| 
       12 
     | 
    
         
            -
                    sudo :service, fetch(:sidekiq_service_unit_name), :reload, *SUPPRESS_FAILURE
         
     | 
| 
       13 
     | 
    
         
            -
                  end
         
     | 
| 
       14 
     | 
    
         
            -
                end
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              desc 'Stop sidekiq (graceful shutdown within timeout, put unfinished tasks back to Redis)'
         
     | 
| 
       18 
     | 
    
         
            -
              task :stop do
         
     | 
| 
       19 
     | 
    
         
            -
                on roles fetch(:sidekiq_roles) do |role|
         
     | 
| 
       20 
     | 
    
         
            -
                  git_plugin.switch_user(role) do
         
     | 
| 
       21 
     | 
    
         
            -
                    sudo :service, fetch(:sidekiq_service_unit_name), :stop, *SUPPRESS_FAILURE
         
     | 
| 
       22 
     | 
    
         
            -
                  end
         
     | 
| 
       23 
     | 
    
         
            -
                end
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
              desc 'Start sidekiq'
         
     | 
| 
       27 
     | 
    
         
            -
              task :start do
         
     | 
| 
       28 
     | 
    
         
            -
                on roles fetch(:sidekiq_roles) do |role|
         
     | 
| 
       29 
     | 
    
         
            -
                  git_plugin.switch_user(role) do
         
     | 
| 
       30 
     | 
    
         
            -
                    sudo :service, fetch(:sidekiq_service_unit_name), :start
         
     | 
| 
       31 
     | 
    
         
            -
                  end
         
     | 
| 
       32 
     | 
    
         
            -
                end
         
     | 
| 
       33 
     | 
    
         
            -
              end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
              desc 'Install upstart sidekiq service'
         
     | 
| 
       36 
     | 
    
         
            -
              task :install do
         
     | 
| 
       37 
     | 
    
         
            -
                on roles fetch(:sidekiq_roles) do |role|
         
     | 
| 
       38 
     | 
    
         
            -
                  git_plugin.switch_user(role) do
         
     | 
| 
       39 
     | 
    
         
            -
                    git_plugin.create_upstart_template
         
     | 
| 
       40 
     | 
    
         
            -
                  end
         
     | 
| 
       41 
     | 
    
         
            -
                end
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              desc 'UnInstall upstart sidekiq service'
         
     | 
| 
       45 
     | 
    
         
            -
              task :uninstall do
         
     | 
| 
       46 
     | 
    
         
            -
                on roles fetch(:sidekiq_roles) do |role|
         
     | 
| 
       47 
     | 
    
         
            -
                  git_plugin.switch_user(role) do
         
     | 
| 
       48 
     | 
    
         
            -
                    execute :rm, '-f',
         
     | 
| 
       49 
     | 
    
         
            -
                            File.join(fetch(:service_unit_path, fetch_upstart_unit_path), fetch(:sidekiq_service_unit_name))
         
     | 
| 
       50 
     | 
    
         
            -
                  end
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
              desc 'Generate service_locally'
         
     | 
| 
       55 
     | 
    
         
            -
              task :generate_service_locally do
         
     | 
| 
       56 
     | 
    
         
            -
                run_locally do
         
     | 
| 
       57 
     | 
    
         
            -
                  File.write('sidekiq.conf', git_plugin.compiled_template)
         
     | 
| 
       58 
     | 
    
         
            -
                end
         
     | 
| 
       59 
     | 
    
         
            -
              end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
              def fetch_upstart_unit_path
         
     | 
| 
       62 
     | 
    
         
            -
                if fetch(:sidekiq_service_unit_user) == :system
         
     | 
| 
       63 
     | 
    
         
            -
                  # if the path is not standard `set :service_unit_path`
         
     | 
| 
       64 
     | 
    
         
            -
                  '/etc/init'
         
     | 
| 
       65 
     | 
    
         
            -
                else
         
     | 
| 
       66 
     | 
    
         
            -
                  home_dir = backend.capture :pwd
         
     | 
| 
       67 
     | 
    
         
            -
                  File.join(home_dir, '.config', 'upstart')
         
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
              end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
              def compiled_template
         
     | 
| 
       72 
     | 
    
         
            -
                search_paths = [
         
     | 
| 
       73 
     | 
    
         
            -
                  File.expand_path(
         
     | 
| 
       74 
     | 
    
         
            -
                    File.join(*%w[.. .. .. generators capistrano sidekiq upstart templates sidekiq.conf.erb]),
         
     | 
| 
       75 
     | 
    
         
            -
                    __FILE__
         
     | 
| 
       76 
     | 
    
         
            -
                  )
         
     | 
| 
       77 
     | 
    
         
            -
                ]
         
     | 
| 
       78 
     | 
    
         
            -
                template_path = search_paths.detect { |path| File.file?(path) }
         
     | 
| 
       79 
     | 
    
         
            -
                template = File.read(template_path)
         
     | 
| 
       80 
     | 
    
         
            -
                ERB.new(template).result(binding)
         
     | 
| 
       81 
     | 
    
         
            -
              end
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
              def create_upstart_template
         
     | 
| 
       84 
     | 
    
         
            -
                ctemplate = compiled_template
         
     | 
| 
       85 
     | 
    
         
            -
                upstart_path = fetch(:service_unit_path, fetch_upstart_unit_path)
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
                backend.execute :mkdir, '-p', upstart_path if fetch(:sidekiq_service_unit_user) != :system
         
     | 
| 
       88 
     | 
    
         
            -
                conf_filename = "#{fetch :sidekiq_service_unit_name}.conf"
         
     | 
| 
       89 
     | 
    
         
            -
                backend.upload!(
         
     | 
| 
       90 
     | 
    
         
            -
                  StringIO.new(ctemplate),
         
     | 
| 
       91 
     | 
    
         
            -
                  "/tmp/#{conf_filename}"
         
     | 
| 
       92 
     | 
    
         
            -
                )
         
     | 
| 
       93 
     | 
    
         
            -
                backend.execute :sudo, :mv, "/tmp/#{conf_filename}", "#{upstart_path}/#{conf_filename}"
         
     | 
| 
       94 
     | 
    
         
            -
                if fetch(:sidekiq_service_unit_user) == :system
         
     | 
| 
       95 
     | 
    
         
            -
                  backend.execute :sudo, :initctl, 'reload-configuration'
         
     | 
| 
       96 
     | 
    
         
            -
                else
         
     | 
| 
       97 
     | 
    
         
            -
                  # backend.execute :sudo, :initctl,  'reload-configuration' #TODO
         
     | 
| 
       98 
     | 
    
         
            -
                end
         
     | 
| 
       99 
     | 
    
         
            -
              end
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
              def num_workers
         
     | 
| 
       102 
     | 
    
         
            -
                fetch(:sidekiq_upstart_num_workers, nil)
         
     | 
| 
       103 
     | 
    
         
            -
              end
         
     | 
| 
       104 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,70 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Source: https://github.com/mperham/sidekiq/blob/master/examples/systemd/sidekiq.service
         
     | 
| 
       2 
     | 
    
         
            -
            #
         
     | 
| 
       3 
     | 
    
         
            -
            # This file tells systemd how to run Sidekiq as a 24/7 long-running daemon.
         
     | 
| 
       4 
     | 
    
         
            -
            #
         
     | 
| 
       5 
     | 
    
         
            -
            # Customize this file based on your bundler location, app directory, etc.
         
     | 
| 
       6 
     | 
    
         
            -
            # Customize and copy this into /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
         
     | 
| 
       7 
     | 
    
         
            -
            # Then run:
         
     | 
| 
       8 
     | 
    
         
            -
            #   - systemctl enable sidekiq
         
     | 
| 
       9 
     | 
    
         
            -
            #   - systemctl {start,stop,restart} sidekiq
         
     | 
| 
       10 
     | 
    
         
            -
            #
         
     | 
| 
       11 
     | 
    
         
            -
            # This file corresponds to a single Sidekiq process.  Add multiple copies
         
     | 
| 
       12 
     | 
    
         
            -
            # to run multiple processes (sidekiq-1, sidekiq-2, etc).
         
     | 
| 
       13 
     | 
    
         
            -
            #
         
     | 
| 
       14 
     | 
    
         
            -
            # Use `journalctl -u sidekiq -rn 100` to view the last 100 lines of log output.
         
     | 
| 
       15 
     | 
    
         
            -
            #
         
     | 
| 
       16 
     | 
    
         
            -
            [Unit]
         
     | 
| 
       17 
     | 
    
         
            -
            Description=sidekiq for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
         
     | 
| 
       18 
     | 
    
         
            -
            # start us only once the network and logging subsystems are available,
         
     | 
| 
       19 
     | 
    
         
            -
            # consider adding redis-server.service if Redis is local and systemd-managed.
         
     | 
| 
       20 
     | 
    
         
            -
            After=syslog.target network.target
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            # See these pages for lots of options:
         
     | 
| 
       23 
     | 
    
         
            -
            #
         
     | 
| 
       24 
     | 
    
         
            -
            #   https://www.freedesktop.org/software/systemd/man/systemd.service.html
         
     | 
| 
       25 
     | 
    
         
            -
            #   https://www.freedesktop.org/software/systemd/man/systemd.exec.html
         
     | 
| 
       26 
     | 
    
         
            -
            #
         
     | 
| 
       27 
     | 
    
         
            -
            # THOSE PAGES ARE CRITICAL FOR ANY LINUX DEVOPS WORK; read them multiple
         
     | 
| 
       28 
     | 
    
         
            -
            # times! systemd is a critical tool for all developers to know and understand.
         
     | 
| 
       29 
     | 
    
         
            -
            #
         
     | 
| 
       30 
     | 
    
         
            -
            [Service]
         
     | 
| 
       31 
     | 
    
         
            -
            #
         
     | 
| 
       32 
     | 
    
         
            -
            #      !!!!  !!!!  !!!!
         
     | 
| 
       33 
     | 
    
         
            -
            #
         
     | 
| 
       34 
     | 
    
         
            -
            # As of v6.0.6, Sidekiq automatically supports systemd's `Type=notify` and watchdog service
         
     | 
| 
       35 
     | 
    
         
            -
            # monitoring. If you are using an earlier version of Sidekiq, change this to `Type=simple`
         
     | 
| 
       36 
     | 
    
         
            -
            # and remove the `WatchdogSec` line.
         
     | 
| 
       37 
     | 
    
         
            -
            #
         
     | 
| 
       38 
     | 
    
         
            -
            #      !!!!  !!!!  !!!!
         
     | 
| 
       39 
     | 
    
         
            -
            #
         
     | 
| 
       40 
     | 
    
         
            -
            Type=notify
         
     | 
| 
       41 
     | 
    
         
            -
            # If your Sidekiq process locks up, systemd's watchdog will restart it within seconds.
         
     | 
| 
       42 
     | 
    
         
            -
            WatchdogSec=10
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
            WorkingDirectory=<%= File.join(fetch(:deploy_to), 'current') %>
         
     | 
| 
       45 
     | 
    
         
            -
            ExecStart=<%= expanded_bundle_path %> exec sidekiq -e <%= fetch(:sidekiq_env) %> <%= sidekiq_config %> <%= sidekiq_concurrency %> <%= sidekiq_queues %>
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
            # Use `systemctl kill -s TSTP sidekiq` to quiet the Sidekiq process
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
            <%="User=#{sidekiq_user}" if sidekiq_user %>
         
     | 
| 
       50 
     | 
    
         
            -
            UMask=0002
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
            <%="EnvironmentFile=#{File.join(fetch(:deploy_to), 'current')}/#{fetch(:sidekiq_service_unit_env_file)}" if fetch(:sidekiq_service_unit_env_file) %>
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
            <% fetch(:sidekiq_service_unit_env_vars, []).each do |environment_variable| %>
         
     | 
| 
       55 
     | 
    
         
            -
              <%="Environment=#{environment_variable}" %>
         
     | 
| 
       56 
     | 
    
         
            -
            <% end %>
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
            # if we crash, restart
         
     | 
| 
       59 
     | 
    
         
            -
            RestartSec=1
         
     | 
| 
       60 
     | 
    
         
            -
            Restart=on-failure
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
            # output goes to /var/log/syslog (Ubuntu) or /var/log/messages (CentOS)
         
     | 
| 
       63 
     | 
    
         
            -
            <%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) %>
         
     | 
| 
       64 
     | 
    
         
            -
            <%="StandardError=append:#{fetch(:sidekiq_error_log)}" if fetch(:sidekiq_error_log) %>
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
            # This will default to "bundler" if we don't specify it
         
     | 
| 
       67 
     | 
    
         
            -
            SyslogIdentifier=sidekiq
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
            [Install]
         
     | 
| 
       70 
     | 
    
         
            -
            WantedBy=default.target
         
     |