From 11ce6449d3a39bd916daa82deb85561f28028013 Mon Sep 17 00:00:00 2001 From: Henare Degan Date: Wed, 20 Feb 2013 15:18:01 +1100 Subject: Upgrade script script/runner by Doing The Dumb Thing. #822 --- script/runner | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'script/runner') diff --git a/script/runner b/script/runner index 2bd5e9aa7..7e910e443 100755 --- a/script/runner +++ b/script/runner @@ -6,7 +6,6 @@ script_dir = File.dirname(__FILE__) alaveteli_dir = File.expand_path(File.join(script_dir, "..")) Dir.chdir(alaveteli_dir) do - require File.join(alaveteli_dir, 'config', 'boot') if daemon_mode # Run in daemon mode. @@ -20,7 +19,7 @@ Dir.chdir(alaveteli_dir) do # Load the runner in a subprocess pid = fork do - require 'commands/runner' + `bundle exec rails runner #{ARGV[1]}` exit 0 end @@ -35,6 +34,6 @@ Dir.chdir(alaveteli_dir) do Process.detach(pid) else # Not daemon mode - require 'commands/runner' + `bundle exec rails runner #{ARGV[1]}` end end -- cgit v1.2.3 From fc7fc117008be617cad6d546e0e1319767a0331f Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 3 Jun 2013 17:18:21 +0100 Subject: Replace backticks with call to exec(), the former spawns a new process, and the latter replaces the current process. In the daemon context we care about the process id so that calls to startstopdaemon won't spawn a new daemon. --- script/runner | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'script/runner') diff --git a/script/runner b/script/runner index 73b03847d..32a0e6b7e 100755 --- a/script/runner +++ b/script/runner @@ -19,12 +19,13 @@ Dir.chdir(alaveteli_dir) do # Load the runner in a subprocess pid = fork do - `bundle exec rails runner #{ARGV[1]}` + exec("bundle exec rails runner #{ARGV[1]}") exit 0 end # If the environment variable PIDFILE is present, # write the pid of the daemon process to that file. + if ENV.has_key? "PIDFILE" File.open(ENV["PIDFILE"], 'w') do |fh| fh.puts pid @@ -34,6 +35,6 @@ Dir.chdir(alaveteli_dir) do Process.detach(pid) else # Not daemon mode - `bundle exec rails runner #{ARGV[1]}` + exec("bundle exec rails runner #{ARGV[1]}") end end -- cgit v1.2.3