Štefan Bartoš Štefan Bartoš - 3 years ago 105
Ruby Question

Rails Spring configuration similar like in Zeus?

I have something like this in Zeus custom plan, where I run some rake tasks:

require 'zeus/rails'

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

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

Zeus.plan = CustomPlan.new

And Zeus config:

"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": {}

And I found this link: https://github.com/rails/spring#configuration, but I don't exactly understand how I can run and stop my custom rake tasks.

I try it something like this:

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

This works, but when I stop spring by
spring stop
is not shutting down.

Is it some clever solution for running and stopping custom rake in spring?


Answer Source

Best solution what I came up for this moment:

# 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 &`

For first I kill all rots and stripe-mock-server if exists and run it again. If you find a better solution, let me know to comment. Thanks.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download