Sha256: 846400f56583eab08964d6df51a68c3948544316494da82bf827047fc3f0c267

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 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 app_env_service_name(worker_number)
          "#{user_app_env_underscore}_#{fetch(:delayed_job_monit_base_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

8 entries across 8 versions & 1 rubygems

Version Path
capistrano-delayed_job-3.1.7 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.1.5 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.1.4 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.1.3 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.1.2 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.1.1 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.0.5 lib/capistrano/helpers/delayed_job/monit.rb
capistrano-delayed_job-3.0.4 lib/capistrano/helpers/delayed_job/monit.rb