CentOS 5.2 Mongrel Cluster
I had to dig these instruction up from archives bow that I switched to Ubuntu 8.10. Everything should still work perfectly fine.
Check to see if Ruby and Gems are already installed on your machine.
gem list --local |
If you nothing happens then you need to install Ruby on Rails and then the gems which should be posted or will be soon. If your getting a list of gems look for mongrel or mongrel_cluster. If your not seeing the gems then you need to install them
sudo gem install mongrel sudo gem install mongrel_cluster |
Once you get them installed now you will need add a user for the service.
/usr/sbin/adduser -r mongrel |
Now we need to create the folder for the mongrel config files
mkdir /etc/mongrel_cluster |
Now we need to copy the mongrel_cluster information to the init.d directory so it can execute. NOTE: this line is very long so it will be on 2 lines and also please note that version change to please check or use auto complete to get the most recent version.
cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.2/ resources/mongrel_cluster /etc/init.d/ |
Now we need this to be executable
chmod +x /etc/init.d/mongrel_cluster |
Now let’s try and start it up
/etc/init.d/mongrel_cluster start && sudo /sbin/chkconfig mongrel_cluster on |
Now everything should be good to go. Here is a sample of the mongrel_cluster.yml file.
user: mongrel cwd: /var/www/vhost/helpdesk.techitweb.com/current log_file: /var/www/vhost/helpdesk.techitweb.com/shared/log/mongrel.log port: "8000" environment: production group: mongrel address: 127.0.0.1 pid_file: /var/www/vhost/helpdesk.techitweb.com/shared/pids/mongrel.pid servers: 3 |
You will need to create a link from the mongrel_cluster.yml file from the project/current/config directory to the /ect/mongrel_cluster folder you created above. It is going to be on two lines because it is so long.
ln -s /var/www/apps/testapp/current/config/mongrel_cluster.yml /etc/mongrel_cluster/helpdeskapp.yml |
Now you will need to change the permissions on the folders so that the mongrel user can write logs and pids
chown -R mongrel.mongrel /var/www/vhost/APPLICATION/shared/log chown -R mongrel.mongrel /var/www/vhost/APPLICATION/shared/pids |
Now that you have everything setup now just setup apache vhost files
<IfModule mod_proxy_balancer.c> <Proxy "balancer://mongrel-cluster"> BalancerMember http://127.0.0.1:8000 BalancerMember http://127.0.0.1:8001 BalancerMember http://127.0.0.1:8002 </Proxy> ProxyPass / balancer://mongrel-cluster/ ProxyPassReverse / balancer://mongrel-cluster/ # ProxyPreserveHost on </IfModule> |
I think that the best way to test this is to do both the /etc/init.d/mongrel_cluster restart and then reboot the machine to make sure it will run after a restart.