Ruby on Rails,脚本/延迟作业启动。什么都没发生

时间:2013-03-17 13:23:41

标签: ruby-on-rails delayed-job

我正在使用以下宝石:

gem 'daemons', "=1.0.10"
gem 'delayed_job_active_record'

和以下命令延迟方法:

after_create:perform_analysis  handle_asynchronously:perform_analysis,:run_at => Proc.new {1.minutes.from_now}

脚本/ delayed_job的:

#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize

所以,我用普通的rails启动应用程序(在tmp / pids中出现一个文件server.pid)。上传一些东西,所以调用create方法。一些数据被插入delayed_jobs表中。我关闭停止运行服务器(在tmp / pids中什么都不存在!)。

然后我写入命令行:

RAILS_ENV=production script/delayed_job start

响应: 在tmp / pids中显示delayed_job.pid并且终端没有显示任何内容,所以我运行:

 kik@kik-VirtualBox:~/Desktop/tors15.01$ RAILS_ENV=production script/delayed_job status
pid-file for killed process 8695 found (/home/kik/Desktop/tors15.01/tmp/pids/delayed_job.pid), deleting.
delayed_job: no instances running

再次尝试我的运气:

kik@kik-VirtualBox:~/Desktop/tors15.01$ RAILS_ENV=production script/delayed_job start
kik@kik-VirtualBox:~/Desktop/tors15.01$ RAILS_ENV=production script/delayed_job run
pid-file for killed process 8718 found (/home/kik/Desktop/tors15.01/tmp/pids/delayed_job.pid), deleting.
SQLite3::SQLException: no such table: delayed_jobs: UPDATE "delayed_jobs" SET locked_by = null, locked_at = null WHERE (locked_by = 'delayed_job host:kik-VirtualBox pid:8724')

当我rake jobs:work时,它正在运作

这是什么原因我在哪里犯了错误? 提前致谢

1 个答案:

答案 0 :(得分:4)

您确定将rails环境设置为生产吗?

script/delayed_job start

RAILS_ENV=development script/delayed_job start