lib/mongrel_cluster/recipes.rb in mongrel_cluster-0.1.1 vs lib/mongrel_cluster/recipes.rb in mongrel_cluster-0.2.0
- old
+ new
@@ -1,43 +1,62 @@
Capistrano.configuration(:must_exist).load do
- set :mongrel_servers, "2"
- set :mongrel_port, "8000"
+ set :mongrel_servers, 2
+ set :mongrel_port, 8000
set :mongrel_address, "127.0.0.1"
set :mongrel_environment, "production"
- set(:mongrel_config) { "#{deploy_to}/config/mongrel_cluster.yml" }
+ set :mongrel_conf, nil
+ set :mongrel_user, nil
+ set :mongrel_group, nil
desc <<-DESC
Configure Mongrel processes on the app server. This uses the :use_sudo
- variable to determine whether to use sudo or not.
+ variable to determine whether to use sudo or not. By default, :use_sudo is
+ set to true.
DESC
task :configure_mongrel_cluster, :roles => :app do
- send(run_method, "if [ ! -d #{File.dirname(mongrel_config)} ]; then mkdir -p #{File.dirname(mongrel_config)}; fi")
- send(run_method, "mongrel_rails cluster::configure -N #{mongrel_servers} -p #{mongrel_port} -e #{mongrel_environment} -a #{mongrel_address} -c #{current_path} -C #{mongrel_config}")
+ set_mongrel_conf
+
+ argv = []
+ argv << "mongrel_rails cluster::configure"
+ argv << "-N #{mongrel_servers.to_s}"
+ argv << "-p #{mongrel_port.to_s}"
+ argv << "-e #{mongrel_environment}"
+ argv << "-a #{mongrel_address}"
+ argv << "-c #{current_path}"
+ argv << "-C #{mongrel_conf}"
+ argv << "--user #{mongrel_user}" if mongrel_user
+ argv << "--group #{mongrel_group}" if mongrel_group
+ cmd = argv.join " "
+ send(run_method, cmd)
end
desc <<-DESC
- Start Mongrel processes on the app server. This uses the :use_sudo
- variable to determine whether to use sudo or not.
+ Start Mongrel processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
+ set to true.
DESC
task :start_mongrel_cluster , :roles => :app do
- send(run_method, "mongrel_rails cluster::start -C #{mongrel_config}")
+ set_mongrel_conf
+ send(run_method, "mongrel_rails cluster::start -C #{mongrel_conf}")
end
desc <<-DESC
- Restart the Mongrel processes on the app server. This uses the :use_sudo
- variable to determine whether to use sudo or not.
+ Restart the Mongrel processes on the app server by starting and stopping the cluster. This uses the :use_sudo
+ variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
DESC
task :restart_mongrel_cluster , :roles => :app do
- send(run_method, "mongrel_rails cluster::restart -C #{mongrel_config}")
+ stop_mongrel_cluster
+ start_mongrel_cluster
end
desc <<-DESC
- Stop the Mongrel processes on the app server. This uses the :use_sudo
- variable to determine whether to use sudo or not.
+ Stop the Mongrel processes on the app server. This uses the :use_sudo
+ variable to determine whether to use sudo or not. By default, :use_sudo is
+ set to true.
DESC
task :stop_mongrel_cluster , :roles => :app do
- send(run_method, "mongrel_rails cluster::stop -C #{mongrel_config}")
+ set_mongrel_conf
+ send(run_method, "mongrel_rails cluster::stop -C #{mongrel_conf}")
end
desc <<-DESC
Restart the Mongrel processes on the app server by calling restart_mongrel_cluster.
DESC
@@ -48,8 +67,12 @@
desc <<-DESC
Start the Mongrel processes on the app server by calling start_mongrel_cluster.
DESC
task :spinner, :roles => :app do
start_mongrel_cluster
+ end
+
+ def set_mongrel_conf
+ set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
end
end
\ No newline at end of file