2017-07-19 93 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是否存在並重新運行。如果您找到更好的解決方案,請發表評論。謝謝。