Sha256: c5a461545994ccf1c20dd2dfc9cd5ab2a223cbf920727b737c56f884acf609eb

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

#!/usr/bin/env ruby
#
# Zena Startup script (automatically generated by 'cap debian:app_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 %>
]

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}..."
  operations.each do |op|
    run "cd #{APP_ROOT} && #{op}start"
  end

  <% if config[:haproxy_port] %>
  # Start haproxy
  run "cd #{APP_ROOT} && haproxy -D -f config/haproxy.cnf"
  <% end %>
end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zena-1.1.3 lib/zena/deploy/app_init.rhtml
zena-1.1.2 lib/zena/deploy/app_init.rhtml
zena-1.1.1 lib/zena/deploy/app_init.rhtml
zena-1.1.0 lib/zena/deploy/app_init.rhtml