Sha256: 2c3dfcebe2175984c2e500db7c4c73e31e12bdcbe03cc497e21ef37d96b1cc79

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

# require cron poller
require 'sidekiq/cron/poller'

# For Cron we need to add some methods to Launcher
# so look at the code bellow.
#
# we are creating new cron poller instance and
# adding start and stop commands to launcher
module Sidekiq
  module Cron
    module Launcher
      # Add cron poller to launcher
      attr_reader :cron_poller

      # add cron poller and execute normal initialize of Sidekiq launcher
      def initialize(options)
        @cron_poller = Sidekiq::Cron::Poller.new
        super(options)
      end

      # execute normal run of launcher and run cron poller
      def run
        super
        cron_poller.start
      end

      # execute normal quiet of launcher and quiet cron poller
      def quiet
        cron_poller.terminate
        super
      end

      # execute normal stop of launcher and stop cron poller
      def stop
        cron_poller.terminate
        super
      end
    end
  end
end

Sidekiq.configure_server do
  # require  Sidekiq original launcher
  require 'sidekiq/launcher'

  ::Sidekiq::Launcher.prepend(Sidekiq::Cron::Launcher)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq-cron-1.6.0 lib/sidekiq/cron/launcher.rb
sidekiq-cron-1.5.1 lib/sidekiq/cron/launcher.rb
sidekiq-cron-1.5.0 lib/sidekiq/cron/launcher.rb
sidekiq-cron-1.4.0 lib/sidekiq/cron/launcher.rb
sidekiq-cron-1.3.0 lib/sidekiq/cron/launcher.rb
sidekiq-cron-1.2.0 lib/sidekiq/cron/launcher.rb