Skip to content

Instantly share code, notes, and snippets.

@xdite
Created August 21, 2008 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdite/6561 to your computer and use it in GitHub Desktop.
Save xdite/6561 to your computer and use it in GitHub Desktop.
# 先在你的 PHP WebApplication 的根目錄建一個目錄, 叫 config , 裡面放置此 rb
# 官方文件 http://www.capify.org/getting-started/rails
# Capistrano PHP http://www.simplisticcomplexity.com/2006/8/16/automated-php-deployment-with-capistrano/
# Capistrano 會用到許多 rake 技巧
# rake 教學請看 http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial
# rake 教學中文版請看 http://hi.baidu.com/%D0%C7203/blog/item/ebda2dd09f1d698ea1ec9c7a.html
#
# ---
# 前置動作
# cd /blah/project
# mkdir config
# cd config; wget http://blah.com/deploy.rb
# 都設完之後 cap deploy:setup
# 會自動去遠端建立
# #{deploy_to}/
# #{deploy_to}/releases (過期版本的 code 都會照日期被移到這裡來,線上版本會在 /current)
# #{deploy_to}/shard (這裡是共用的檔案,可以放靜態檔案,不需重 deploy)
# #{deploy_to}/shard/log
# #{deploy_to}/shard/system
# #{deploy_to}/shard/pids
set :application, "blah"
# 這裡填 APP 名稱
set :repository, "https://svnpath.com/blah/"
# 這裡填 SVN repository
# 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, "/home/prorject"
# 遠端欲 deploy 的目錄
set :user, "project_user"
# 負責此工作的 ssh 帳號名稱
set :password, "password"
# 負責此工作的帳號密碼
set :port, "222"
# ssh port
set :rake, "/usr/bin/rake" # Ubuntu Slice
# 遠端 server 的 rake 位置
set :group, "pixgroup"
set :scm_username, "pixsvn"
# svn user name
set :scm_password, "pixpassword"
# svn password
set :scm_command, "/usr/bin/svn"
# svn path
#
set :use_sudo, false
ssh_options[:paranoid] = false
default_environment["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games" # Ubuntu Slice
# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion
role :app, "67.207.129.40"
role :web, "67.207.129.40"
role :db, "67.207.129.40", :primary => true
namespace :deploy do
desc "Create database.yml and asset packages for production"
task :after_update_code, :roles => [:web] do
# update code 完作某事
# 比如有一些敏感 config 是不會進 scm
# 可以從 shared 複製到 current
db_config = "#{shared_path}/config/database.yml.production"
run <<-EOF
cp #{db_config} #{release_path}/config/database.yml
EOF
run <<-EOF
ln -s #{shared_path}/upload #{latest_release}/public/upload
EOF
end
desc "Restart Mongrel"
task :restart, :roles => [:app] do
# 重開 web server, mongrel 是 RoR 的,當然也可以改換成重開 apache
run <<-EOF
cd #{current_path} && mongrel_rails cluster::restart
EOF
end
desc "Find out svn version on server"
task :what_version, :roles => [:app] do
stream <<-CMD
svn info #{current_path}/app
CMD
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment