我在宙斯定制计划中有这样的东西,我执行一些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 stop
停止spring时,stripe-mock-server
并没有关闭。
这是一个聪明的解决方案运行和停止自定义耙在春季?
谢谢
发布于 2017-07-24 23:55:03
我现在想出的最好的解决方案:
# 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
首先,如果存在,我会杀死所有的rots
和stripe-mock-server
,然后再次运行。如果你找到更好的解决办法,让我知道评论。谢谢。
https://stackoverflow.com/questions/45192734
复制相似问题