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

标签 ruby-on-rails delayed-job

我正在使用以下 gem :

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

并使用以下命令来延迟该方法:

创建后:执行分析 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时,它正在工作

这是什么原因,我哪里做错了? 提前致谢

最佳答案

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

script/delayed_job start

RAILS_ENV=development script/delayed_job start

关于ruby-on-rails - Ruby on Rails,脚本/延迟作业启动。什么都没发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15461219/

相关文章:

ruby-on-rails - Rails 3.1 路由——集合不工作

ruby-on-rails - Ransack:如何使用现有范围?

ruby-on-rails - rspec - 如何检查 allow_blank 是否存在

ruby-on-rails - 使用 Kernel#fork 进行后台进程,专业人士?缺点?

ruby-on-rails - 在 GitLab 中发送新用户通知的问题

mysql - MySQL 上的延迟作业 : 'This version of MySQL doesn' t yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

ruby-on-rails - 如何在 guard for rspec 中运行单个测试?

ruby-on-rails - 自定义 Ruby 方法不适用于 nil 对象

ruby-on-rails - Delayed_job : Undefined method error on any call

ruby-on-rails - 延迟作业 ActiveRecord::Job Load - 每 5 秒运行一次?