0

我在 Zeus 自定义计划中有类似的东西,我在其中运行一些 rake 任务:

require 'zeus/rails'

class CustomPlan < Zeus::Rails
  def rots
    `bundle exec rots 1> log/rots.log &`
  end

  def stripe_mock
    `bundle exec stripe-mock-server 1> log/stripe-mock-server.log &`
  end
end

Zeus.plan = CustomPlan.new

宙斯配置:

{
    "command": "ruby -rubygems -r./custom_plan -eZeus.go",

    "plan": {
      "boot": {
        "default_bundle": {
        "development_environment": {
        "prerake": {"rake": []},
        "console": ["c"]
      },
      "test_environment": {
        "test_helper": {"test": ["rspec"]}
      }
    },
    "rots": {},
    "stripe_mock": {}
    }
  }
}

我找到了这个链接:https ://github.com/rails/spring#configuration ,但我并不完全了解如何运行和停止我的自定义 rake 任务。

我尝试这样的事情:

class CustomPlan
  def initialize
    `bundle exec rots 1> log/rots.log &`
    `bundle exec stripe-mock-server 1> log/stripe-mock-server.log &`
  end
end
CustomPlan.new

这有效,但是当我停止 spring 时spring stopstripe-mock-server并没有关闭。

这是在春季运行和停止自定义耙子的一些聪明的解决方案吗?

谢谢

4

1 回答 1

0

我现在想出的最佳解决方案:

# config/spring.rb
Spring.after_fork do
  `killall -v -9 rots & bundle exec rots 1> log/rots.log &`
  `killall -v -9 stripe-mock-server & bundle exec stripe-mock-server 1> log/stripe-mock-server.log &`
end

首先,我杀死所有rotsstripe-mock-server如果存在并再次运行它。如果您找到更好的解决方案,请告诉我评论。谢谢。

于 2017-07-25T07:55:03.080 回答