module Scheduler
Constants
- VERSION
Attributes
configuration[RW]
@return [Scheduler::Configuration] the configuration class for Scheduler
.
Public Class Methods
configure() { |configuration| ... }
click to toggle source
Method to configure various Scheduler
options.
@return [nil]
# File lib/scheduler.rb, line 24 def configure @configuration ||= Scheduler::Configuration.new yield @configuration end
pid()
click to toggle source
Gets scheduler main process pid.
@return [Integer] main process pid.
# File lib/scheduler.rb, line 41 def pid File.read(self.pid_file).to_i rescue nil end
pid_file()
click to toggle source
Gets scheduler pid file.
@return [String] the pid file.
# File lib/scheduler.rb, line 33 def pid_file '/tmp/rails-scheduler.pid' end
restart()
click to toggle source
Restarts the scheduler.
@return [nil]
# File lib/scheduler.rb, line 81 def restart self.stop self.start end
start()
click to toggle source
Starts a Scheduler::MainProcess
in a separate process.
@return [nil]
# File lib/scheduler.rb, line 49 def start scheduler_pid = Process.fork do begin Process.daemon(true) File.open(self.pid_file, 'w+') do |pidfile| pidfile.puts Process.pid end scheduler = Scheduler::MainProcess.new rescue StandardError => e Rails.logger.error "#{e.class}: #{e.message} (#{e.backtrace.first})".red end end Process.detach(scheduler_pid) scheduler_pid end
stop()
click to toggle source
Reschedules all running jobs and stops the scheduler main process.
@return [nil]
# File lib/scheduler.rb, line 69 def stop begin Process.kill :TERM, Scheduler.pid FileUtils.rm(self.pid_file) rescue TypeError, Errno::ENOENT, Errno::ESRCH end end