Sha256: 3cce7962002fe4eeb7e36cc99c82468d0fa8f8c6d536d2b8246d277caf700ce0

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

module Capistrano
  module Helpers
    module DelayedJob
      ##
      # Module Monit provides helpers for Monit/Puma combination
      ##
      module Monit
        module_function

        def pid_file(worker_number)
          service_pid("#{service_name(worker_number)}")
        end

        def service_name(worker_number)
          "#{fetch(:delayed_job_monit_base_service_name)}_#{worker_number}"
        end

        def start_command(worker_number)
          "/bin/bash -c '[ ! -h #{runit_service_path(service_name(worker_number))}/run ] || /usr/bin/sv start #{runit_service_path(service_name(worker_number))}'" # rubocop:disable Metrics/LineLength
        end

        def stop_command(worker_number)
          # Give delayed job 60 seconds to finish any jobs it's currently handling.
          # (Tasks that are longer than 60 seconds should be split!)
          "/usr/bin/sv -w 60 force-stop #{runit_service_path(service_name(worker_number))}" # rubocop:disable Metrics/LineLength
        end

        def available_configuration_with_path(worker_number)
          File.join(fetch(:monit_available_path), "#{service_name(worker_number)}.conf")
        end

        def available_configuration_file(worker_number)
          "#{service_name(worker_number)}.conf"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-delayed_job-3.0.3 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.0.2 lib/capistrano/helpers/delayed_job/monit.rb