ranmocy / guard-rails

Guard-Rails is watching on your development servers as you wish!
http://ranmocy.github.com/guard-rails
MIT License
137 stars 25 forks source link

Guard keeps restarting Rails #12

Closed leebrooks0 closed 11 years ago

leebrooks0 commented 11 years ago

Every now and then Guard keeps restarting and stopping Rails repeatedly. I have to exit Guard and restart it to stop this problem. For instance when I run a Rake task to recreate the database and add sample data I get something like this:

>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
12:05:00 - INFO - Rails restarted, pid 4018

12:05:01 - INFO - Running annotate
Nothing annotated.
Route file annotated.
12:05:12 - INFO - Reloading browser: /assets/application.css
12:05:12 - INFO - Restarting Rails...

>> Stopping ...
Exiting
=> Booting Thin
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
12:05:21 - INFO - Rails restarted, pid 4057

12:05:21 - INFO - Running annotate
Nothing annotated.
Route file annotated.
12:05:32 - INFO - Reloading browser: /assets/application.css
12:05:32 - INFO - Restarting Rails...

>> Stopping ...
Exiting
=> Booting Thin
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
12:05:41 - INFO - Rails restarted, pid 4091

12:05:41 - INFO - Running annotate
Nothing annotated.
Route file annotated.
12:05:52 - INFO - Restarting Rails...

>> Stopping ...
Exiting
=> Booting Thin
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
12:06:01 - INFO - Rails restarted, pid 4124
ranmocy commented 11 years ago

Could you paste your Guardfile? Thanks.

leebrooks0 commented 11 years ago
# A sample Guardfile
# More info at https://github.com/guard/guard#readme \

ignore %r{^.idea}

guard 'annotate', notify: false, routes: true, tests: true, show_indexes: true do
  watch( 'db/schema.rb' )

  # Uncomment the following line if you also want to run annotate anytime
  # a model file changes
  #watch( 'app/models/**/*.rb' )

  # Uncomment the following line if you are running routes annotation
  # with the ":routes => true" option
  watch( 'config/routes.rb' )
end

guard 'coffeescript', :input => 'app/assets/javascripts',:noop => true, :hide_success => true

guard 'livereload' do
  watch(%r{app/views/.+\.(erb|haml|slim)$})
  watch(%r{app/views/.+\.(erb|haml|slim)$})
  watch(%r{app/presenters/.+\.rb})
  watch(%r{public/.+\.(css|js|html)})
  watch(%r{config/locales/.+\.yml})
  # Rails Assets Pipeline
  watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
end

guard 'minitest' do
  # with Minitest::Unit
  watch(%r|^test/(.*)\/?test_(.*)\.rb|)
  watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  watch(%r|^test/test_helper\.rb|)    { "test" }

  # with Minitest::Spec
  # watch(%r|^spec/(.*)_spec\.rb|)
  # watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  # watch(%r|^spec/spec_helper\.rb|)    { "spec" }

  # Rails 3.2
  # watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/controllers/#{m[1]}_test.rb" }
  # watch(%r|^app/helpers/(.*)\.rb|)     { |m| "test/helpers/#{m[1]}_test.rb" }
  # watch(%r|^app/models/(.*)\.rb|)      { |m| "test/unit/#{m[1]}_test.rb" }

  # Rails
  # watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/functional/#{m[1]}_test.rb" }
  # watch(%r|^app/helpers/(.*)\.rb|)     { |m| "test/helpers/#{m[1]}_test.rb" }
  # watch(%r|^app/models/(.*)\.rb|)      { |m| "test/unit/#{m[1]}_test.rb" }
end

#guard 'rails',force_run: true do
#  watch('Gemfile.lock')
#  watch(%r{^(config|lib)/.*})
#end

guard 'sass', :input => 'app/assets/stylesheets', :noop => true, :hide_success => true
ranmocy commented 11 years ago

I think it is a bug of Guard-annotate, I test the Guardfile like this:

guard 'annotate', notify: false, routes: true, tests: true, show_indexes: true do
  watch( 'db/schema.rb' )

  # Uncomment the following line if you also want to run annotate anytime
  # a model file changes
  #watch( 'app/models/**/*.rb' )

  # Uncomment the following line if you are running routes annotation
  # with the ":routes => true" option
  watch( 'config/routes.rb' )
end

When I saving the file db/schema.rb, annotate will keep restarting to die. And output like this:

09:05:31 - INFO - Running annotate
Nothing annotated.
Route file annotated.
09:05:38 - INFO - Running annotate
Nothing annotated.
Route file annotated.
09:05:46 - INFO - Running annotate
Nothing annotated.
Route file annotated.
09:05:53 - INFO - Running annotate
Nothing annotated.
Route file annotated.
09:06:01 - INFO - Running annotate
Nothing annotated.

My version of Guard-annotate is the latest:

    guard-annotate (1.1.0)
      annotate (>= 2.4.0)
      guard (>= 0.2.2)

And the endless issue is metioned here https://github.com/cpjolicoeur/guard-annotate/issues/2

So the issue is that the guard-annotate keep restarting to die, and every time it runs, it trying to save the config/routes.rb file. Which will restart your rails as your Guardfile rules saying so.