4

So I have a weird situation, I have delayed_job 2.0.7 and daemons 1.0.10 and ruby 1.87 & rails 2.3.5 running on Scientific Linux release 6.3 (Carbon).

I have a rake task that restarts delayed jobs each night and then does a bunch of batch processing. I used to just do ruby script/delayed_job stop and then start. I have added a backport of named queues that has allowed me to do named queues. So because of this I want to start several processes of each type of named queue. To do this, it seems the best way I found is to use -i to name each process differently so they don't collide.

I wrote some ruby code to do this looping and it works great in dev, it works great on the command line, it works great when called from the rails console. But when called from cron it fails silently, the call returns false but no error message.

# this works
system_call_result1 = %x{ruby script/delayed_job stop}
SnapUtils.log_to_both "result of stop all - #{system_call_result1} ***"

# this works
system_call_result2 = %x{mv log/delayed_job.log log/delayed_job.log.#{Date.today.to_s}}
SnapUtils.log_to_both "dj log file has been rotated"

# this fails, result is empty string, if I use system I get false returned
for x in 1..DELAYED_JOB_MAX_THREAD_COUNT
  system_call_result = %x{ruby script/delayed_job -i default-#{x} start}
  SnapUtils.log_to_both "result of start default queue iteration #{x} - #{system_call_result} ***"
end

# this fails the same way
for y in 1..FOLLOWERS_DELAYED_JOB_MAX_THREAD_COUNT
  system_call_result = %x{ruby script/delayed_job --queue=follower_ids -i follower_ids-#{y} start}
  SnapUtils.log_to_both "result of start followers queue iteration #{y} - #{system_call_result} ***"
end

So I did lots of trial and found that this problem only happens if I used -i - named processes and only happens if I stop them, then try to start them. If I remove the stops then everything works fine.

Again this is only when I use cron.

If I use command line or console to run, it works fine.

So my question is, what could cron be doing differently that causes these named dj processes not to start if you previously stopped them in the same ruby process?

thanks Joel

4

1 回答 1

2

好吧,我终于想通了,当检查 cron 是否会发送电子邮件时,我们发现 sendmail 坏了,没有安装 sendmail 想要的 mysql 版本,所以我们修复了这个问题,然后我们的问题神奇地消失了。我仍然会向任何可以解释原因的人提供赏金..

于 2013-04-25T20:28:59.893 回答