使用Capistrano部署apache+mongrel cluster
来源:互联网 发布:中国气象数据共享网 编辑:程序博客网 时间:2024/05/21 19:46
部署任务:
机器1 192.168.100.231, os: CentOS release 3.6 (Final),装上apache2.3.6+mongrel cluster
机器2 192.168.100.234, os: CentOS release 4.3 (Final) 装上 mongrel cluster
关于配置apache+mongrel cluster本文不再赘述,请看本人的文章
安装和配置Apache + mongrel cluster
关于Capistrano的基础,请看本人的文章
使用Capistrano部署rails
在这边文章中主要使用了Capistrano部署了一个单实例的mongrel 服务器,并且也只部署了一台机器
基于前两篇的基础,本文描述了如何使用Capistrano部署apache+mongrel cluster应用到多台机器
重点就是 deploy.rb
set :application, "space"
set :repository, "http://192.168.100.212:3690/repo/moxtv/branches/space"
set :svn_username, "weip"
set :svn_password, "weip"
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"
# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion
set :use_sudo,false
set :deploy_to, "/var/www/webapps/#{application}"
set :user, "root"
set :password, "secretpa"
role :app, "192.168.100.231","192.168.100.234" #new 0
role :web, "192.168.100.231"
role :db, "192.168.100.231", :primary => true
task :chmod, :roles => :web do
run "chmod -fR 755 #{deploy_to}/current/script/*"
end
after "deploy:symlink", :chmod
default_environment["PATH"] ="/usr/local/ruby2/bin:/usr/local/apache2.2.6/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/ruby/bin:/usr/local/ant/bin:/usr/java/jdk1.5.0_05/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin"
#new 1
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
set :mongrel_port, "4000"
set :mongrel_nodes, "4"
#new 2
namespace :deploy do
task :start, :roles => :app do
run "cd #{current_path} && mongrel_rails cluster::configure -e production -p #{mongrel_port} -N #{mongrel_nodes} -c #{current_path} "
run "cd #{current_path} && mongrel_rails cluster::start"
#run "rm -rf /home/#{user}/public_html;ln -s #{current_path}/public /home/#{user}/public_html"
run "mkdir -p #{deploy_to}/shared/config"
run "mv #{current_path}/config/mongrel_cluster.yml #{deploy_to}/shared/config/mongrel_cluster.yml"
run "ln -s #{deploy_to}/shared/config/mongrel_cluster.yml #{current_path}/config/mongrel_cluster.yml"
run "apachectl start"
end
end
#new 3
namespace :deploy do
task :restart, :roles => :app do
run "ln -s #{deploy_to}/shared/config/mongrel_cluster.yml #{current_path}/config/mongrel_cluster.yml"
run "cd #{current_path} && mongrel_rails cluster::restart"
run "apachectl restart"
end
end
set :repository, "http://192.168.100.212:3690/repo/moxtv/branches/space"
set :svn_username, "weip"
set :svn_password, "weip"
# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"
# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion
set :use_sudo,false
set :deploy_to, "/var/www/webapps/#{application}"
set :user, "root"
set :password, "secretpa"
role :app, "192.168.100.231","192.168.100.234" #new 0
role :web, "192.168.100.231"
role :db, "192.168.100.231", :primary => true
task :chmod, :roles => :web do
run "chmod -fR 755 #{deploy_to}/current/script/*"
end
after "deploy:symlink", :chmod
default_environment["PATH"] ="/usr/local/ruby2/bin:/usr/local/apache2.2.6/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/ruby/bin:/usr/local/ant/bin:/usr/java/jdk1.5.0_05/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin"
#new 1
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
set :mongrel_port, "4000"
set :mongrel_nodes, "4"
#new 2
namespace :deploy do
task :start, :roles => :app do
run "cd #{current_path} && mongrel_rails cluster::configure -e production -p #{mongrel_port} -N #{mongrel_nodes} -c #{current_path} "
run "cd #{current_path} && mongrel_rails cluster::start"
#run "rm -rf /home/#{user}/public_html;ln -s #{current_path}/public /home/#{user}/public_html"
run "mkdir -p #{deploy_to}/shared/config"
run "mv #{current_path}/config/mongrel_cluster.yml #{deploy_to}/shared/config/mongrel_cluster.yml"
run "ln -s #{deploy_to}/shared/config/mongrel_cluster.yml #{current_path}/config/mongrel_cluster.yml"
run "apachectl start"
end
end
#new 3
namespace :deploy do
task :restart, :roles => :app do
run "ln -s #{deploy_to}/shared/config/mongrel_cluster.yml #{current_path}/config/mongrel_cluster.yml"
run "cd #{current_path} && mongrel_rails cluster::restart"
run "apachectl restart"
end
end
主要修改了#new 0 ,并删除了单实例mongrel中的spin文件
并加了3个部分,#new1,#new2,#new3
#new1 设置了些 与 mongrel cluster相关的变量
#new2 #new3 分别重写了deploy:start和deploy:restart任务
这样就防止了默认的任务去寻找相关的spin文件
配置文件准备就绪,然后cap setup,cap deploy:cold,cap deploy
- 使用Capistrano部署apache+mongrel cluster
- 使用Capistrano部署rails
- 使用 Capistrano 部署总结
- 使用 Capistrano 部署总结
- 安装和配置Apache + mongrel cluster
- 使用 Capistrano —— Rails应用快速部署工具
- capistrano 部署rails
- 自动化部署实践capistrano
- Capistrano集群部署CloudFoundry
- mongrel cluster中的敏感字符:Cluster
- Ubuntu下Mongrel和mongrel cluster的配置
- capistrano/blob/v3.4.0部署
- rails + capistrano + nginx + puma部署
- capistrano从安装到部署
- capistrano中的脚本使用
- 配置apache +mongrel单实例
- 在linux平台,使用capistrano, rvm, passenger来部署 rails 项目
- Fedora 9 下使用apache+mongrel+rails轻松架设ROR应用
- 关于int型整数按逆序存入数组中的问题(也即十进制数和其他类型数据的转换问题)
- Ajax Modules
- ASP.NET 动态页面静态化 比较
- web打印+套打问题
- td中内容自动换行
- 使用Capistrano部署apache+mongrel cluster
- 记录用反射方式操作属性或变量
- 不确定有穷自动机 NFA 与 隐马尔可夫模型 HMM 比较
- 美丽Oracle之-Oracle第一天 理论、常用权限命令
- StringBuffer与String的一点区别
- MVC模式的讨论与struts1.x和Struts2的比较
- FastCGI Extension for IIS 下载
- 客户端在发送邮件的时候,邮件服务器返回Relaying denied错误的解决方法
- How do I get start in QA/Test