capistrano - 一个脚本可以部署多个服务器

访问量: 131

补记一下

# -*- encoding : utf-8 -*-
require 'capistrano-rbenv'
load 'deploy/assets'
ssh_options[:port] = 33233
set :rake, "bundle exec rake"

set :copy_local_tar, "/usr/bin/gnutar" if RUBY_PLATFORM.match(/darwin/)
set :application, "mobile CMS"
set :repository, "."
set :scm, :none
set :deploy_via, :copy
SERVER_TEST_32 = "10.103.23.32"
SERVER_TEST_103 = "10.103.23.103"
SERVER_PRODUCTION_121 = "10.103.23.121"
SERVER_PRODUCTION_11 = "10.103.23.11"
SERVER_PRODUCTION_73 = "10.103.23.73"
SERVER_PRODUCTION_74 = "10.103.23.74"

set(:server_type) {
  puts "== 测试服务器是:  test103 (.32 已经废弃,不过有需要的话仍然可以上去)"
  puts "== 正式服务器是:  73, 74 "
  Capistrano::CLI.ui.ask("== which server do you want to deploy to? (test103/test32/73/74)? ")
}
case server_type.chomp
  when 'test32'
    server = SERVER_TEST_32
    password = 'Q7sKxQoM8'
  when 'test103'
    server = SERVER_TEST_103
    password = 'v6piiz9cx'
  when '11'
    server = SERVER_PRODUCTION_11
    password = 'no need for password'
  when '121'
    server = SERVER_PRODUCTION_121
    password = 'YopmwECgn'
  when '73'
    server = SERVER_PRODUCTION_73
    password = 'avCNz7gv6'
  when '74'
    server = SERVER_PRODUCTION_74
    password = 'N0NYxtZCo'
end
puts "== password for #{server} is: #{password}"

role :web, server
role :app, server
role :db,  server, :primary => true
role :db,  server

set :deploy_to, "/opt/app/ruby/m-cms"
default_run_options[:pty] = true

# change to your username
set :user, "root"

namespace :deploy do
  task :start do

订阅/RSS Feed

Subscribe

分类/category