Skip to content

Commit

Permalink
Fixin indent on new Utility module.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfsekaran committed Sep 11, 2013
1 parent eecee4a commit a4c7f49
Showing 1 changed file with 45 additions and 43 deletions.
88 changes: 45 additions & 43 deletions lib/capistrano-unicorn/utility.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
module CapistranoUnicorn
module Utility

def local_unicorn_config
File.exist?(unicorn_config_rel_file_path) ?
unicorn_config_rel_file_path
: unicorn_config_stage_rel_file_path
unicorn_config_rel_file_path
: unicorn_config_stage_rel_file_path
end

def extract_pid_file
tmp = Tempfile.new('unicorn.rb')
begin
conf = local_unicorn_config
tmp.write <<-EOF.gsub(/^ */, '')
config_file = "#{conf}"
config_file = "#{conf}"
# stub working_directory to avoid chdir failure since this will
# run client-side:
def working_directory(path); end
# stub working_directory to avoid chdir failure since this will
# run client-side:
def working_directory(path); end
instance_eval(File.read(config_file), config_file) if config_file
puts set[:pid]
exit 0
instance_eval(File.read(config_file), config_file) if config_file
puts set[:pid]
exit 0
EOF
tmp.close
extracted_pid = `unicorn -c "#{tmp.path}"`
Expand Down Expand Up @@ -85,12 +86,12 @@ def try_unicorn_user
#
def kill_unicorn(signal)
script = <<-END
if #{unicorn_is_running?}; then
echo "Stopping Unicorn...";
#{unicorn_send_signal(signal)};
else
echo "Unicorn is not running.";
fi;
if #{unicorn_is_running?}; then
echo "Stopping Unicorn...";
#{unicorn_send_signal(signal)};
else
echo "Unicorn is not running.";
fi;
END

script
Expand All @@ -100,39 +101,39 @@ def kill_unicorn(signal)
#
def start_unicorn
%Q%
if [ -e "#{unicorn_config_file_path}" ]; then
UNICORN_CONFIG_PATH=#{unicorn_config_file_path};
else
if [ -e "#{unicorn_config_stage_file_path}" ]; then
UNICORN_CONFIG_PATH=#{unicorn_config_stage_file_path};
else
echo "Config file for "#{unicorn_env}" environment was not found at either "#{unicorn_config_file_path}" or "#{unicorn_config_stage_file_path}"";
exit 1;
fi;
fi;
if [ -e "#{unicorn_pid}" ]; then
if #{try_unicorn_user} kill -0 `cat #{unicorn_pid}` > /dev/null 2>&1; then
echo "Unicorn is already running!";
exit 0;
fi;
#{try_unicorn_user} rm #{unicorn_pid};
fi;
echo "Starting Unicorn...";
cd #{app_path} && #{try_unicorn_user} RAILS_ENV=#{rails_env} BUNDLE_GEMFILE=#{bundle_gemfile} #{unicorn_bundle} exec #{unicorn_bin} -c $UNICORN_CONFIG_PATH -E #{unicorn_rack_env} -D #{unicorn_options};
if [ -e "#{unicorn_config_file_path}" ]; then
UNICORN_CONFIG_PATH=#{unicorn_config_file_path};
else
if [ -e "#{unicorn_config_stage_file_path}" ]; then
UNICORN_CONFIG_PATH=#{unicorn_config_stage_file_path};
else
echo "Config file for "#{unicorn_env}" environment was not found at either "#{unicorn_config_file_path}" or "#{unicorn_config_stage_file_path}"";
exit 1;
fi;
fi;
if [ -e "#{unicorn_pid}" ]; then
if #{try_unicorn_user} kill -0 `cat #{unicorn_pid}` > /dev/null 2>&1; then
echo "Unicorn is already running!";
exit 0;
fi;
#{try_unicorn_user} rm #{unicorn_pid};
fi;
echo "Starting Unicorn...";
cd #{app_path} && #{try_unicorn_user} RAILS_ENV=#{rails_env} BUNDLE_GEMFILE=#{bundle_gemfile} #{unicorn_bundle} exec #{unicorn_bin} -c $UNICORN_CONFIG_PATH -E #{unicorn_rack_env} -D #{unicorn_options};
%
end

def duplicate_unicorn
script = <<-END
if #{unicorn_is_running?}; then
echo "Duplicating Unicorn...";
#{unicorn_send_signal('USR2')};
else
#{start_unicorn}
fi;
if #{unicorn_is_running?}; then
echo "Duplicating Unicorn...";
#{unicorn_send_signal('USR2')};
else
#{start_unicorn}
fi;
END

script
Expand All @@ -141,5 +142,6 @@ def duplicate_unicorn
def unicorn_roles
defer{ fetch(:unicorn_roles, :app) }
end

end
end

0 comments on commit a4c7f49

Please sign in to comment.