lib/good_job/cli.rb in good_job-1.5.0 vs lib/good_job/cli.rb in good_job-1.6.0
- old
+ new
@@ -13,10 +13,15 @@
class CLI < Thor
# Path to the local Rails application's environment configuration.
# Requiring this loads the application's configuration and classes.
RAILS_ENVIRONMENT_RB = File.expand_path("config/environment.rb")
+ # @!visibility private
+ def self.exit_on_failure?
+ true
+ end
+
# @!macro thor.desc
# @!method $1
# @return [void]
# The +good_job $1+ command. $2
desc :start, "Executes queued jobs."
@@ -25,11 +30,12 @@
All options can be configured with environment variables.
See option descriptions for the matching environment variable name.
== Configuring queues
- \x5Separate multiple queues with commas; exclude queues with a leading minus;
+
+ Separate multiple queues with commas; exclude queues with a leading minus;
separate isolated execution pools with semicolons and threads with colons.
DESCRIPTION
method_option :max_threads,
type: :numeric,
@@ -41,12 +47,20 @@
desc: "Queues to work from. (env var: GOOD_JOB_QUEUES, default: *)"
method_option :poll_interval,
type: :numeric,
banner: 'SECONDS',
desc: "Interval between polls for available jobs in seconds (env var: GOOD_JOB_POLL_INTERVAL, default: 5)"
+ method_option :daemonize,
+ type: :boolean,
+ desc: "Run as a background daemon (default: false)"
+ method_option :pidfile,
+ type: :string,
+ desc: "Path to write daemonized Process ID (env var: GOOD_JOB_PIDFILE, default: tmp/pids/good_job.pid)"
def start
set_up_application!
configuration = GoodJob::Configuration.new(options)
+
+ Daemon.new(pidfile: configuration.pidfile).daemonize if configuration.daemonize?
notifier = GoodJob::Notifier.new
poller = GoodJob::Poller.new(poll_interval: configuration.poll_interval)
scheduler = GoodJob::Scheduler.from_configuration(configuration)
notifier.recipients << [scheduler, :create_thread]