Sha256: 0a6a182c169ffb4cf9a89ee57ac78c8fa2bca8809368e11176ef8c992334b0d3

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 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 = [
  'ruby lib/upload_progress_server.rb ',
  'rake worker:',
<% if config[:app_type] == :mongrel %>
  'mongrel_rails cluster::',
<% end %>  
  # 'rake sphinx:',
]

if %w{stop restart}.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
end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zena-1.2.1 lib/zena/deploy/app_init.rhtml
zena-1.2.0 lib/zena/deploy/app_init.rhtml