On Aug 9, 2007, at 6:25 PM, Michael Steinfeld wrote:
> Hi --
>
> I have been reading documentation and googling around to find the
> correct way to do this but I have found many ways that seem to not
> work, or the documentation makes no reference to.
>
> I am using mongrel cluster with 10 mongrels for each server. Recently
> I installed monit but which lead me to find the correct way to
> start/stop mongrel instances one pid at a time. I am assuming one pid
> at a time is the correct way...
>
> Currently, when I do a cap deploy we just kick mongrels with
> /etc/init.d/mongrel_rails.. I am assuming I should be using monit now
> when I deploy to do this. Correct? Can you give me an example of this?
> I know this is not the monit list, but I was thinking you guys know
> what I am talking about.
So the better way to go about it is to use mongrel_cluster with the
--clean and --only options. Here is a monit file that works very well:
check process mongrel_warehouse_5000
with pidfile /data/warehouse/shared/log/mongrel.5000.pid
start program = "/usr/bin/mongrel_rails cluster::start -C /data/
warehouse/current/config/mongrel_cluster.yml --clean --only 5000"
stop program = "/usr/bin/mongrel_rails cluster::stop -C /data/
warehouse/current/config/mongrel_cluster.yml --clean --only 5000"
if totalmem is greater than 110.0 MB for 3 cycles then
restart # eating up memory?
if loadavg(5min) greater than 10 for 8 cycles then
restart # bad, bad, bad
if 20 restarts within 20 cycles then
timeout # something is wrong, call the sys-admin
group mongrel
You must have the latest version of mongrel_cluster installed for
the --clean option. Then to restart in your deploy.rb set
the :monit_group variable and use these tasks for restarting:
set : monit_group, 'mongrel'
desc <<-DESC
Restart the Mongrel processes on the app server by calling
restart_mongrel_cluster.
DESC
task :restart, :roles => :app do
restart_mongrel_cluster
end
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
desc <<-DESC
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
sudo "/usr/bin/monit start all -g #{monit_group}"
end
desc <<-DESC
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
sudo "/usr/bin/monit restart all -g #{monit_group}"
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. By
default, :use_sudo is
set to true.
DESC
task :stop_mongrel_cluster , :roles => :app do
sudo "/usr/bin/monit stop all -g #{monit_group}"
end
Cheers-
-- Ezra Zygmuntowicz
-- Founder & Ruby Hacker
-- [EMAIL PROTECTED]
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)
_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users