Skip to content
vjfrancois edited this page Apr 8, 2014 · 1 revision

Background scripts

In the background, tasks are run periodically to update the stocks and the fleets status. Two utilities manage and run the background tasks :

  • clockwork is a simple tool, configured to periodically add the update tasks in the job queue. It is currently set to 10 seconds. Gem clockwork
  • Delayed_job is the task manager. The job queue is stored in the database. One (or more) worker takes the next jobs in line and execute thems. Gem delayed_job

Currently, the main task is an update of the stock of a zone with the Zone method .product! Clockwork add a "update stock" job every X seconds. This job then update every zone where the next_production_time is in the past.

Clockwork and delayed_job can be run in separate terminals :

$ clockwork lib/clockwork.rb

and

$ rake jobs:work

or in daemons (with start, stop, status) (does not work in windows...) :

$ clockworkd -c lib/clockwork.rb start
$ script/delayed_job start

Clone this wiki locally