lib/guard/rails/runner.rb in guard-rails-0.1.1 vs lib/guard/rails/runner.rb in guard-rails-0.2.0

- old
+ new

@@ -16,12 +16,16 @@ wait_for_pid end def stop if File.file?(pid_file) - system %{kill -SIGINT #{File.read(pid_file).strip}} + pid = File.read(pid_file).strip + system %{kill -SIGINT #{pid}} wait_for_no_pid if $?.exitstatus == 0 + + # If you lost your pid_file, you are already died. + system %{kill -KILL #{pid} > /dev/null 2>&1} FileUtils.rm pid_file, :force => true end end def restart @@ -31,21 +35,22 @@ def build_rails_command rails_options = [ '-e', options[:environment], '-p', options[:port], - '--pid', pid_file + '--pid', pid_file, + options[:daemon] ? '-d' : '', + options[:debugger] ? '-u' : '', + options[:server].nil? ? '' : options[:server], ] - rails_options << '-d' if options[:daemon] - rails_options << '-u' if options[:debugger] - rails_options << options[:server] if options[:server] + rails_runner = options[:zeus] ? 'zeus' : 'rails' - %{sh -c 'cd #{Dir.pwd} && RAILS_ENV=#{options[:environment]} rails s #{rails_options.join(' ')} &'} + %{sh -c 'cd #{Dir.pwd} && RAILS_ENV=#{options[:environment]} #{rails_runner} s #{rails_options.join(' ')} &'} end def pid_file - File.expand_path("tmp/pids/#{options[:environment]}.pid") + File.expand_path(options[:pid_file] || "tmp/pids/#{options[:environment]}.pid") end def pid File.file?(pid_file) ? File.read(pid_file).to_i : nil end