lib/recipes/centos/mongrel_cluster.rb in capitate-0.3.5 vs lib/recipes/centos/mongrel_cluster.rb in capitate-0.3.6

- old
+ new

@@ -5,60 +5,26 @@ namespace :centos do desc <<-DESC Create mongrel cluster. - <dl> - <dt>mongrel_application</dt> - <dd>Name of mongrel application</dd> - <dd>@set :mongrel_application, "mongrel_cluster_\#{application}"@</dd> + "Source":#{link_to_source(__FILE__)} + DESC - <dt>mongrel_size</dt><dd>Number of mongrels</dd> - <dd>@set :mongrel_size, 3@</dd> + task_arg(:mongrel_application, "Name of mongrel application") + task_arg(:mongrel_size, "Number of mongrels") + task_arg(:mongrel_port, "Starting port for mongrels. If there are 3 mongrels with port 9000, then instances will be at 9000, 9001, and 9002") + task_arg(:mongrel_config_dir, "Directory for mongrel config", :default => Proc.new{"#{shared_path}/config/mongrel"}, :default_desc => "\#{shared_path}/config/mongrel") + task_arg(:mongrel_pid_dir, "Directory for mongrel pids", :default => Proc.new{"#{shared_path}/pids"}, :default_desc => "\#{shared_path}/pids") + task_arg(:mongrel_config_script, "Config script to load with mongrel", :default => nil) - <dt>mongrel_port</dt><dd>Starting port for mongrels. If there are 3 mongrels with port 9000, - then instances will be at 9000, 9001, and 9002</dd> - <dd>@set :mongrel_port, 9000@</dd> + task_arg(:mongrel_cluster_command, "Mongrel cluster command", :default => "mongrel_cluster_ctl") + task_arg(:mongrel_initscript_name, "Mongrel initscript name", :default => Proc.new{"mongrel_cluster_#{application}"}, :default_desc => "mongrel_cluster_\#{application}") + task_arg(:mongrel_config_options, "Config options appended to cluster yml", :default => {}) - <dt>mongrel_config_dir</dt> - <dd>Directory for mongrel config.</dd> - <dd class="default">Defaults to @\#{shared_path}/config/mongrel@</dd> - - <dt>mongrel_pid_dir</dt><dd>Directory for mongrel pids</dd> - <dd class="default">Defaults to @\#{shared_path}/pids@</dd> - - <dt>mongrel_config_script</dt><dd>Config script to load with mongrel</dd> - <dd class="default">Defaults to @nil@</dd> - <dd>@set :mongrel_config_script, "config/mongrel_handler.rb"@</dd> - - <dt>mongrel_cluster_command</dt> - <dd>Mongrel cluster command.</dd> - <dd class="default">Defaults to @mongrel_cluster_ctl@</dd> - - <dt>mongrel_initscript_name</dt><dd>Mongrel initscript name.</dd> - <dd class="default">Defaults to @mongrel_cluster_\#{application}@</dd> - - <dt>mongrel_config_options</dt> - <dd>Config options appended to cluster yml.</dd> - <dd class="default">Defaults to @{}@</dd> - - </dl> - "Source":#{link_to_source(__FILE__)} - DESC task :setup do - - # Settings - fetch(:mongrel_size) - fetch(:mongrel_port) - fetch_or_default(:mongrel_config_dir, "#{shared_path}/config/mongrel") - fetch_or_default(:mongrel_pid_dir, "#{shared_path}/pids") - fetch_or_default(:mongrel_config_script, nil) - fetch_or_default(:mongrel_cluster_command, "mongrel_cluster_ctl") - fetch_or_default(:mongrel_initscript_name, "mongrel_cluster_#{application}") - fetch_or_default(:mongrel_config_options, {}) - unless mongrel_config_script.blank? mongrel_config_options["config_script"] = mongrel_config_script end run "mkdir -p #{mongrel_config_dir}" @@ -70,16 +36,14 @@ initscript end desc "Mongrel cluster setup initscript for application" + task_arg(:mongrel_config_dir, "Directory for mongrel config", :default => Proc.new{"#{shared_path}/config/mongrel"}, :default_desc => "\#{shared_path}/config/mongrel") + task_arg(:mongrel_pid_dir, "Directory for mongrel pids", :default => Proc.new{"#{shared_path}/pids"}, :default_desc => "\#{shared_path}/pids") + task_arg(:mongrel_cluster_command, "Mongrel cluster command", :default => "mongrel_cluster_ctl") + task_arg(:mongrel_initscript_name, "Mongrel initscript name", :default => Proc.new{"mongrel_cluster_#{application}"}, :default_desc => "mongrel_cluster_\#{application}") task :initscript do - - fetch_or_default(:mongrel_config_dir, "#{shared_path}/config/mongrel") - fetch_or_default(:mongrel_pid_dir, "#{shared_path}/pids") - fetch_or_default(:mongrel_cluster_command, "mongrel_cluster_ctl") - fetch_or_default(:mongrel_initscript_name, "mongrel_cluster_#{application}") - utils.install_template("mongrel/mongrel_cluster.initd.centos.erb", "/etc/init.d/#{mongrel_initscript_name}") run_via "/sbin/chkconfig --level 345 #{mongrel_initscript_name} on" end end \ No newline at end of file