【问题标题】:Running heroku CLI commands (rake db:migrate) from Resque worker从 Resque worker 运行 heroku CLI 命令 (rake db:migrate)
【发布时间】:2016-01-05 03:27:13
【问题描述】:

我正在尝试运行 heroku CLI 命令,例如:

heroku run rake db:migrate --app app-name
heroku run rake db:seed --app app-name

来自在后台运行的 Resque 工作人员。

如果我在前台运行工人:

RAILS_ENV=production rake resque:work QUEUE="*"

进程成功完成,rake 任务开始运行。

但是,当工人像这样启动时:

RAILS_ENV=production PIDFILE=./resque.pid BACKGROUND=yes QUEUE="*" rake resque:work >>  worker1.log

进程静默失败,没有迹象表明日志中发生了什么。有没有办法在后台运行这些任务?

【问题讨论】:

  • 你为什么要从工人那里执行这些任务?迁移和播种都应由开发人员在推送迁移后手动完成 - 开发人员应确保迁移和播种成功。对不起,如果我是逆向的,但我就是不明白你为什么要这样做。

标签: ruby-on-rails ruby heroku resque heroku-toolbelt


【解决方案1】:

就像 max 说的我不确定你为什么要这样做,但是如果你想从 Ruby 脚本调用 Rake 任务,在你的情况下,最好将 Rake 任务实际加载到内存中并运行它从您的 Resque 工作人员内部。这是一个解释如何从 Ruby 运行 Rake 任务的 SO 答案:https://stackoverflow.com/a/15259172/586983

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-08
    • 2017-07-30
    • 2014-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-19
    相关资源
    最近更新 更多