2017-07-19 45 views
0

我在宙斯的定制计划,在那里我运行一些rake任务是这样的:Rails弹簧配置与Zeus类似吗?

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,但我不正确理解我可以如何运行和停止我的自定义佣金任务。

我尝试它是这样的:

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 stop停止春天,stripe-mock-server没有关闭。

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

感谢

回答

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是否存在并重新运行。如果您找到更好的解决方案,请发表评论。谢谢。