lib/good_job/configuration.rb in good_job-1.5.0 vs lib/good_job/configuration.rb in good_job-1.6.0
- old
+ new
@@ -10,21 +10,20 @@
# Default number of seconds between polls for jobs
DEFAULT_POLL_INTERVAL = 5
# Default number of seconds to preserve jobs for {CLI#cleanup_preserved_jobs}
DEFAULT_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO = 24 * 60 * 60
- # @!attribute [r] options
- # The options that were explicitly set when initializing +Configuration+.
- # @return [Hash]
- #
- # @!attribute [r] env
- # The environment from which to read GoodJob's environment variables. By
- # default, this is the current process's environment, but it can be set
- # to something else in {#initialize}.
- # @return [Hash]
- attr_reader :options, :env
+ # The options that were explicitly set when initializing +Configuration+.
+ # @return [Hash]
+ attr_reader :options
+ # The environment from which to read GoodJob's environment variables. By
+ # default, this is the current process's environment, but it can be set
+ # to something else in {#initialize}.
+ # @return [Hash]
+ attr_reader :env
+
# @param options [Hash] Any explicitly specified configuration options to
# use. Keys are symbols that match the various methods on this class.
# @param env [Hash] A +Hash+ from which to read environment variables that
# might specify additional configuration values.
def initialize(options, env: ENV)
@@ -106,17 +105,31 @@
).to_i
end
# Number of seconds to preserve jobs when using the +good_job cleanup_preserved_jobs+ CLI command.
# This configuration is only used when {GoodJob.preserve_job_records} is +true+.
- # @return [Boolean]
+ # @return [Integer]
def cleanup_preserved_jobs_before_seconds_ago
(
options[:before_seconds_ago] ||
rails_config[:cleanup_preserved_jobs_before_seconds_ago] ||
env['GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO'] ||
DEFAULT_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO
).to_i
+ end
+
+ # Tests whether to daemonize the process.
+ # @return [Boolean]
+ def daemonize?
+ options[:daemonize] || false
+ end
+
+ # Path of the pidfile to create when running as a daemon.
+ # @return [Pathname,String]
+ def pidfile
+ options[:pidfile] ||
+ env['GOOD_JOB_PIDFILE'] ||
+ Rails.application.root.join('tmp', 'pids', 'good_job.pid')
end
private
def rails_config