guard-rails 神秘重启

guard-rails mysteriously restarting

我从 rails-4.2.7.1 升级到 5.0.1,现在当我 运行 guard 它出于某种原因自动重启。这导致它尝试启动 Rails 的第二个实例,但因为已经有一个 运行ning.

而死了
» bundle exec guard
Expected string default value for '--listen-on'; got false (boolean)
17:57:54 - INFO - Bundle already up-to-date
17:57:54 - INFO - [Guard::Rails] will start the default web server on port 3000 in development.
17:57:54 - INFO - Starting Rails...
DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <top (required)> at /home/istrasci/dev/rails/credalizer/config/application.rb:9)
=> Booting Puma
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.2 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
17:58:03 - INFO - Rails started, pid 9732
17:58:03 - INFO - Guard::RSpec is running
17:58:03 - INFO - [Guard::Yard] Stopping YARD Documentation Server.
17:58:03 - INFO - [Guard::Yard] Starting YARD Documentation Server.
17:58:03 - INFO - LiveReload is waiting for a browser to connect.
>> YARD 0.9.5 documentation server at http://localhost:8808
Puma starting in single mode...
* Version 3.6.2 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:8808
Use Ctrl-C to stop
17:58:04 - INFO - [Guard::Yard] Server successfully started.
* Restarting...     <------------------------------------------- HERE
17:58:06 - INFO - Guard is now watching at '/home/istrasci/dev/rails/credalizer'
[1] guard(main)> DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1. Use before_action instead. (called from <top (required)> at /home/istrasci/dev/rails/credalizer/config/application.rb:9)
=> Booting Puma
=> Rails 5.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
A server is already running. Check /home/istrasci/dev/rails/credalizer/tmp/pids/development.pid.
Exiting

然后运行ning的实例没有响应,只好手动删除这个tmp/pids/development.pid文件或者退出守卫提示.我的守卫-rails 在 Rails 中工作正常 4. 有人知道为什么会这样吗?


这是我的 Guardfile

notification :gntp if RUBY_PLATFORM =~ /darwin/i
notification :libnotify if RUBY_PLATFORM =~ /linux/i

guard :bundler do
  watch('Gemfile')
end

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

guard :rspec, cmd: 'bin/rspec' do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }

  # Rails example
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$})          { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  watch('spec/rails_helper.rb')                       { "spec" }

  # FactoryGirl factory files
  begin
    require 'active_support/inflector'
    watch(%r{^spec/factories/(.+)\.rb$})      { |m| "spec/models/#{m[1].singularize}_spec.rb" }
    watch(%r{^spec/factories/document_data.rb}) { |m| "spec/models/document_data_spec.rb" }
  rescue LoadError
  end

  # Capybara features specs
  watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$})     { |m| "spec/features/#{m[1]}_spec.rb" }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

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

guard 'yard' do
  watch(%r{app/.+\.rb})
  watch(%r{lib/.+\.rb})
  watch(%r{ext/.+\.c})
end

大家好,我是 guard-rails 的维护者。 作为我的测试,最小的错误 Guardfile 看起来像:

guard 'rails'
guard 'yard'

问题是,由于未知原因,guard-yard 在启动过程中停止并重新启动 Puma 服务器。这是 Rails 5.0 中引入的默认开发服务器。如果 rails 已经启动,它会杀死服务器并导致它重新启动但失败。

你需要做的只是交换它们:

guard 'yard'
guard 'rails'

事实上,我认为 guard-yard 绝对不应该杀死 rails 服务器。