lib/guard/rails/runner.rb in guard-rails-0.3.1 vs lib/guard/rails/runner.rb in guard-rails-0.3.2
- old
+ new
@@ -5,10 +5,11 @@
MAX_WAIT_COUNT = 10
attr_reader :options
def initialize(options)
+ @env = ENV
@options = options
end
def start
kill_unmanaged_pid! if options[:force_run]
@@ -34,10 +35,12 @@
end
def build_rails_command
return %{#{options[:CLI]} --pid #{pid_file}} if options[:CLI]
+ @env['RAILS_ENV'] = options[:environment] if options[:environment]
+
rails_options = [
options[:daemon] ? '-d' : nil,
options[:debugger] ? '-u' : nil,
'-e', options[:environment],
'--pid', pid_file,
@@ -48,11 +51,11 @@
zeus_options = [
options[:zeus_plan] || 'server',
]
# omit env when use zeus
- rails_runner = options[:zeus] ? "zeus #{zeus_options.join(' ')}" : "RAILS_ENV=#{options[:environment]} rails server"
+ rails_runner = options[:zeus] ? "zeus #{zeus_options.join(' ')}" : "rails server"
%{#{rails_runner} #{rails_options.join(' ')}}
end
def pid_file
@@ -67,10 +70,10 @@
options[:timeout].to_f / MAX_WAIT_COUNT.to_f
end
private
def run_rails_command!
- system "sh -c '#{build_rails_command}'"
+ Process.spawn @env, build_rails_command
end
def has_pid?
File.file?(pid_file)
end