1

I was making a script that runs periodically to make some code inside my rails app using rufus scheduler (I used it with daemon specifically to work on production server). But it is not working at all as it terminates and kill the process.

Here is my script/rufus_schedule file

#!/usr/bin/env ruby

root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))

require 'rubygems'
require 'rufus/scheduler'
gem 'daemons'
require 'daemons'

options = {
  :dir_mode   => :normal,
  :dir        => File.join(root,'log'),
  :log_output => true,
  :backtrace  => true,
  :multiple   => false
}

Daemons.run_proc("rufus_schedule", options) do
  scheduler = Rufus::Scheduler.start_new

  scheduler.every '10s' do
    BloodDonationUtil.clear_requests_after(7)
  end
end
tshepang
  • 12,111
  • 21
  • 91
  • 136
Shimaa Marzouk
  • 429
  • 4
  • 10

1 Answers1

2

I don't know what you mean by "kill the process", I guess you mean "it exits immediately".

Please read: https://github.com/jmettraux/rufus-scheduler#schedulerjoin

Add at the end of your script:

scheduler.join
jmettraux
  • 3,511
  • 3
  • 31
  • 30
  • i got error message on terminal when starting script telling that process of that script killed. plus i gor this in my script log file:# # # # # – Shimaa Marzouk Jun 25 '13 at 18:24
  • You're giving out bits and pieces of information but the whole picture is absent. You have to learn how to get support. – jmettraux Jun 26 '13 at 04:46
  • You're giving out bits and pieces of information but the big picture cannot be derived from this information. You have to learn how to ask for help in an intelligible way. http://www.chiark.greenend.org.uk/~sgtatham/bugs.html might help you. Remember: people cannot read your mind and they know nothing about your setting and context. Give them enough information to help you, not disjoint bits. Thanks for the error messages, but what do the error messages and the back traces look like? It might help if you posted your script log file to https://gist.github.com/ and linked to it from here. – jmettraux Jun 26 '13 at 04:51