mardi 10 mai 2016

How to start clock task using passenger & nginx on production

I deploy my project using passenger & nginx.

How can i run clock task on server. I used Clockwork gem.

This is my clock task (lib/clock.rb) :

# require boot & environment for a Rails app
require_relative "../config/boot"
require_relative "../config/environment"

require 'clockwork'

module Clockwork

  handler do |job|
    puts "Running #{job}"
  end

  every 10.minutes, 'send detail' do
    ::User.periodically_send_detail
  end
end

Locally i can run bundle exec clockwork lib/clock.rb and it's working. It send detail on every 10 seconds.

On heroku i add bundle exec clockwork lib/clock.rb to Procfile like (NOTE: extra charge will be applied for clock) :

clock:  bundle exec clockwork lib/clock.rb

Works on heroku also.

But how can i run this clock file with passenger and nginx server on production startup ?

Any extra information required then tell me i will provide.

Aucun commentaire:

Enregistrer un commentaire