Posted over 9 years ago
mongrel_cluster service is not starting the mongrel cluster |
I ran into an issue setting up a service to start mongrel_cluster on boot. I followed an excellent set of instructions that I found here, but I ran into a couple problems.
Problem 1: service mongrel_cluster start gives no output and does not start the cluster
I looked through the init script and found that the script called mongrel_cluster_ctl to start the cluster. So I logged in as root and ran the command.
# sudo su
# mongrel_cluster_ctl start
The program 'mongrel_cluster_ctl' is currently not installed. You can install it by typing:
apt-get install mongrel-cluster
Ah! update $PATH for root to include gems.
Issue the following command to get the path to mongrel_cluster_ctl
which mongrel_cluster_ctl
Then edit /etc/init.d/mongrel_cluster to add the full path to mongrel_cluster_ctl to the inti script
Now test.
# sudo su
# mongrel_cluster_ctl start
Starting all mongrel_clusters...
# ps -ef | grep mongrel
root 860 834 0 20:22 pts/2 00:00:00 grep --color=auto mongrel
Progress! … but still no cluster
Problem 2: mongrel_cluster_ctl does not start the cluster
After much searching I finally found a reference to adding cwd:
Bam! It works!
~$ sudo su
# mongrel_cluster_ctl start
Starting all mongrel_clusters...
# ps -ef | grep mongrel
root 1289 1 86 20:36 ? 00:00:01 /usr/bin/ruby1.8 /var/lib/gems/1.8/bin/mongrel_rails
root 1292 1 99 20:36 ? 00:00:01 /usr/bin/ruby1.8 /var/lib/gems/1.8/bin/mongrel_rails
root 1295 1 99 20:36 ? 00:00:01 /usr/bin/ruby1.8 /var/lib/gems/1.8/bin/mongrel_rails
root 1298 1247 0 20:36 pts/2 00:00:00 grep --color=auto mongrel
# service mongrel_cluster stop
Stopping all mongrel_clusters...
# ps -ef | grep mongrel
root 1278 1247 0 20:36 pts/2 00:00:00 grep --color=auto mongrel
# service mongrel_cluster start
Starting all mongrel_clusters...
# ps -ef | grep mongrel
root 1289 1 86 20:36 ? 00:00:01 /usr/bin/ruby1.8 /var/lib/gems/1.8/bin/mongrel_rails
root 1292 1 99 20:36 ? 00:00:01 /usr/bin/ruby1.8 /var/lib/gems/1.8/bin/mongrel_rails
root 1295 1 99 20:36 ? 00:00:01 /usr/bin/ruby1.8 /var/lib/gems/1.8/bin/mongrel_rails
root 1298 1247 0 20:36 pts/2 00:00:00 grep --color=auto mongrel
Problem 3: mongrel_cluster is not restarting during capistrano deploy
Since I had created a custom restart task in my deploy.rb (to restart passenger), capistrano was not restarting the mongrel servers. I had to add a new line in that task to force the mongrel server restart. Here is my deploy.rb
require 'mongrel_cluster/recipes'
set :application, "blog" set :repository, "<my repo>" set :branch, "master" set :deploy_to, "/var/www/blog" set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml" set :user, "root" #set :use_sudo, true #default_run_options[:pty] = true
set :scm, :git # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
role :web, "<my server>" # Your HTTP server, Apache/etc role :app, "<my server>" # This may be the same as your `Web` server role :db, "<my server>", :primary => true # This is where Rails migrations will run
# If you are using Passenger mod_rails uncomment this: # if you're still using the script/reapear helper you will need # these http://github.com/rails/irs_process_scripts
namespace :deploy do task :start do ; end task :stop do ; end task :restart, :roles => :app, :except => { :no_release => true } do run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" run "cd #{release_path} && mongrel_rails cluster::restart" # Restarts mongrel clusters end desc "Update the crontab file" task :update_crontab, :roles => :db do run "cd #{release_path} && whenever --update-crontab #{application}" end end
after "deploy:symlink", "deploy:update_crontab" after "deploy", "deploy:migrate"