我正在使用以下宝石:
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 }
脚本/延迟作业:
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize
所以,我用通常的 rails s 启动应用程序(在 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
它正在工作
这是什么原因导致我在哪里做错了?提前致谢