Ruby on rails: How to run a background task automatically when the server starts? -


i have created rails application runs background process. pings server periodically , displays graph response time. using gem called crono. starting task command line using 'bundle exec crono'.

how can run background process automatically when rails server starts without having start command line?

also, there way automatically refresh page periodically displays updated graph?

edit: application deployed production.
edit: still couldn't work. here's folder structure:


application/config/
ping_job.rb
cronotab.rb

cronotab uses 'crono' gem execute task inside ping_job.rb every 5 seconds.

require 'typhoeus'
class pingjob
  def peform

   #task definition goes here.

  end
end

i want run task defined in ping_job.rb automatically when server starts. thinking of using whenever gem. , suggestions welcome.

put in config/environment.rb right under rails.application.initialize! ran start rails server, run after application initialized


Comments