Method: Epi::Jobs.beat!
- Defined in:
- lib/epi/jobs.rb
.beat! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/epi/jobs.rb', line 29 def beat! # Cancel any scheduled beats EventMachine.cancel_timer @next_beat if @next_beat # Make sure configuration files have been read refresh_config! # Snapshot currently running processes ProcessStatus.take! # Get rid of jobs for config files that have been removed clean_configuration_files! # Create new jobs make_new_jobs! # Sync each job with its expectations each_value &:sync! # Snapshot processes again, so that triggers have access to # newly-spawned processes ProcessStatus.take! # Run job triggers each_value &:run_triggers! # Write state of each job to data file Data.jobs = map { |id, job| [id.to_s, job.state] }.to_h Data.save # Schedule the next beat @next_beat = EventMachine.add_timer(interval) { beat! } end |