Sha256: 9643ee50bbffd4b2686f3a980c4befdee89f18c1fcd698d4ed57a54d488fa9ce

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 KB

Contents

#!/usr/bin/env ruby
#
# Zena Startup script (automatically generated by 'cap debian:setup')
#
# chkconfig: - 85 15
# description: zena_<%= config[:db_name] %> starts and stop services for <%= config[:db_name] %> Zena application.
#
ROOT = "<%= config[:deploy_to] %>"
APP_ROOT = "#{ROOT}/current"

cmd = ARGV.first

def run(cmd)
  puts cmd
  system(cmd)
end

operations = [
  'rake worker:',
<% if config[:app_type] == :mongrel %>
  'ruby lib/upload_progress_server.rb ',
  'mongrel_rails cluster::',
<% end %>  
  # 'rake sphinx:',
]

# Allways make a clean start
if %w{stop restart start}.include?(cmd)
  puts "Stopping #{APP_ROOT}..."
  operations.each do |op|
    run "cd #{APP_ROOT} && #{op}stop"
  end

  <% if config[:haproxy_port] %>
  # Stop haproxy
  pid_file = "#{ROOT}/shared/pids/haproxy.pid"
  if File.exist?(pid_file) && pid = File.read("#{ROOT}/shared/pids/haproxy.pid")
    run "kill #{pid}"
  end
  <% end %>
end

if %w{start restart}.include?(cmd)
  puts "Starting #{APP_ROOT}..."
  
  <% if config[:haproxy_port] %>
  # Start haproxy first
  run "cd #{APP_ROOT} && haproxy -D -f config/haproxy.cnf"
  <% end %>
  # Clear to make sure it all starts cleanly and we do not hang with
  # dangling pid files.
  run "cd #{APP_ROOT} && rm log/mongrel*.pid"
  operations.each do |op|
    run "cd #{APP_ROOT} && #{op}start"
  end
  
  <% if config[:app_type] == :passenger %>
  # Restart Passenger
  run "cd #{APP_ROOT} && touch tmp/restart.txt"
  <% end %>
end

unless %w{start stop restart}.include?(cmd)
  puts "Usage: zena_<%= config[:db_name] %> {start|stop|restart}"
  exit
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zena-1.2.8 lib/zena/deploy/app_init.rhtml
zena-1.2.7 lib/zena/deploy/app_init.rhtml
zena-1.2.6 lib/zena/deploy/app_init.rhtml
zena-1.2.5 lib/zena/deploy/app_init.rhtml
zena-1.2.4 lib/zena/deploy/app_init.rhtml
zena-1.2.3 lib/zena/deploy/app_init.rhtml