Apache / Passenger rufus cron工作不工作 [英] Apache/Passenger rufus cron job not working

查看:275
本文介绍了Apache / Passenger rufus cron工作不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Apache / Passenger上运行的Rails应用程序。我有一个rufus cron作业,在后台运行并通过电子邮件发送通知。当我在WEBrick服务器上运行开发中的应用程序时,电子邮件被发送,就像他们应该被发送。当我在Apache / Passenger上生产应用程序时,电子邮件不会发送。这个工作的类是在config / initializers / task_scheduler.rb

I have a Rails app running on Apache/Passenger. I have a rufus cron job that runs in the background and sends out notifications via email. When I am running the app in development on the WEBrick server, the emails are sent like they are supposed to be sent. When I start up the app in production on Apache/Passenger, then the emails dont get sent. The class doing the work is in config/initializers/task_scheduler.rb

require 'rubygems'
require 'rufus/scheduler'

Rails.logger.info "Starting the scheduler"

## to start scheduler
scheduler = Rufus::Scheduler.start_new


## Every day at 6 AM, send email for projects that haven't been updated in 14 days
Rails.logger.info "Adding the Stale Email job to the scheduler"
scheduler.cron("* * * * *") do
  Rails.logger.info "Running every minute"
  projects = Project.stale
  projects.each do |project|
    Rails.logger.info "Inside the loop"
    days = (Time.now - project.updated_at).to_i / 1.day
    ProjectMailer.stale(Jetway::Application.config.stale_email, project, days).deliver
    Rails.logger.info "Sent stale email for project #{project.name}; it's #{days} days stale."
  end
end

现在它每分钟都在运行,所以我可以调试。这是我的日志文件输出。

Right now it is running every minute, so I can debug. Here is my log file output.

Started GET "/assets/availity_spinner.gif" for 99.44.242.76 at 2012-06-23 21:46:28 -0400
Served asset /availity_spinner.gif - 304 Not Modified (0ms)
Starting the scheduler
Adding the Stale Email job to the scheduler

您可以看到日志语句以及我们进入代码的距离。我已经阅读在博客中,乘客杀死线程,特别是围绕cron工作。我被困,并试图找到一个方向来解决这个问题。请指点我的方向。

You can see the log statement and how far we get into the code. I have read in blogs that Passenger kills threads, specifically around cron jobs. I am stuck and trying to get a direction to figure out this issue. Please point me in the right direction.

推荐答案

将以下行添加到您的apache2配置并重新启动apache2服务器

Add the below lines to your apache2 config and restart your apache2 server

RailsAppSpawnerIdleTime 0
PassengerMinInstances 1

这篇关于Apache / Passenger rufus cron工作不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆