Will deferred work run based on server time?

I am using delayed_job in my rails application. I want to run a delayed_job based on a table column that is stored in UTC. My server setup is in EST. Will the job delay take UTC or EST?

+3


source to share


1 answer


If you are using active_record_delayed_job

then your application's timezone specified in application.rb

.

Below is the source of delayed_job ( https://github.com/collectiveidea/delayed_job_active_record/blob/master/lib/delayed/backend/active_record.rb#L97 )

    # Get the current time (GMT or local depending on DB)
    # Note: This does not ping the DB to get the time, so all your clients
    # must have syncronized clocks.
    def self.db_time_now
      if Time.zone
        Time.zone.now
      elsif ::ActiveRecord::Base.default_timezone == :utc
        Time.now.utc
      else
        Time.now
      end
    end

      

and this is used in reserve_with_scope

which queries the DB for available jobs (starting at line 56)



If you are not sure what timezone is set in your application, you can use the following from the rails console

2.1.4 :005 > Rails.application.config.time_zone
 => "Helsinki"

      

or

2.1.4 :007 > Time.zone.name
 => "Helsinki" 

      

+1


source







All Articles