Last active
April 27, 2021 07:48
-
-
Save zxzsaga/7bd05b5f22f6f367efdd to your computer and use it in GitHub Desktop.
Revisions
-
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -146,3 +146,4 @@ Capistrano v3 提供了默认的 deploy flow 和 rollback flow. ## Tips - `%w(a bb ccc)` 等于 `["a", "bb", "ccc"]` - 在 Capistrano v3 里不能用`cap dev deploy -s branch=en/3.1`这种方法来传递参数了,新的方法可以看这里<http://stackoverflow.com/questions/21027452/capistrano-3-pulling-command-line-arguments> -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -84,7 +84,7 @@ fetch(:special_thing, 'some_default_value') ### 变量定义 - `:application` application 名称 - `:deploy_to` 远端服务器部署的根目录。 `default: -> { "/var/www/#{fetch(:application)}" }` - `:scm` 所使用的版本管理系统。 `default: :git` - `:repo_url` 代码库的 url - `:repo_path` 远端服务器代码存放路径。 `default: -> { "#{fetch(:deploy_to)}/repo" }` -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -142,4 +142,7 @@ set :branch, 'master' ## Flow Capistrano v3 提供了默认的 deploy flow 和 rollback flow. <http://capistranorb.com/documentation/getting-started/flow/> ## Tips - `%w(a bb ccc)` 等于 `["a", "bb", "ccc"]` -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -131,4 +131,15 @@ role :web, %w{hello@world.com example.com:1234} # using extended syntax (which is equivalent) server 'world.com', roles: [:web], user: 'hello' server 'example.com', roles: [:web], port: 1234 ``` ### 配置 VCS ``` set :application, 'rails3-bootstrap-devise-cancan-demo' set :repo_url, 'https://github.com/capistrano/rails3-bootstrap-devise-cancan' set :branch, 'master' ``` ## Flow Capistrano v3 提供了默认的 deploy flow 和 rollback flow. <http://capistranorb.com/documentation/getting-started/flow/> -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -120,4 +120,15 @@ end ``` set :database_password, ask('Enter the database password:', 'default', echo: false) ``` ## 准备应用 ### 配置服务器地址 ``` # using simple syntax role :web, %w{hello@world.com example.com:1234} # using extended syntax (which is equivalent) server 'world.com', roles: [:web], user: 'hello' server 'example.com', roles: [:web], port: 1234 ``` -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -114,4 +114,10 @@ task :breakfast do execute "echo \"$(whoami) wants #{fetch(:breakfast)} for breakfast!\"" end end ``` 用`ask`语句获取用户输入,可以用`echo: false`参数让用户输入不显示: ``` set :database_password, ask('Enter the database password:', 'default', echo: false) ``` -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -99,3 +99,19 @@ fetch(:special_thing, 'some_default_value') - `:pty` - `:log_level` - `:format` ## 用户输入 ``` # used in a configuration set :database_name, ask('Enter the database name:') # used in a task desc "Ask about breakfast" task :breakfast do ask(:breakfast, "pancakes") on roles(:all) do |h| execute "echo \"$(whoami) wants #{fetch(:breakfast)} for breakfast!\"" end end ``` -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -84,10 +84,10 @@ fetch(:special_thing, 'some_default_value') ### 变量定义 - `:application` application 名称 - `:deploy_tp` 远端服务器部署的根目录。 `default: -> { "/var/www/#{fetch(:application)}" }` - `:scm` 所使用的版本管理系统。 `default: :git` - `:repo_url` 代码库的 url - `:repo_path` 远端服务器代码存放路径。 `default: -> { "#{fetch(:deploy_to)}/repo" }` - `:repo_tree` - `:linked_files` - `:linked_dirs` -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -84,10 +84,10 @@ fetch(:special_thing, 'some_default_value') ### 变量定义 - `:application` application 名称 - `:deploy_tp` 远端服务器部署的根目录。 `default: -> {"/var/www/#{fetch(:application)}" }` - `:scm` 所使用的版本管理系统。 `default: :git` - `:repo_url` 代码库的 url - `:repo_path` 远端服务器代码存放路径。 `default: -> {"#{fetch(:deploy_to)}/repo" }` - `:repo_tree` - `:linked_files` - `:linked_dirs` -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,6 +54,7 @@ set :deploy_to, '/var/www/my_app_name' └── <linked_files and linked_dirs> ``` 其中, - `current` 是指向最新版本的指针 - `releases` 存放了所有版本的文件,并以时间戳命名。 `current` 指针指向这些目录中的一个。 - `repo` 存放版本管理系统的配置。如果是 Git 则会是一个完整的 git repository. -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,9 @@ └── capistrano └── tasks ``` 其中, - `Capfile` 用来配置 Capistrano - `deploy.rb` 定义共用的 tasks - `production.rb/staging.rb` 定义具体的 stage 的 tasks -
zxzsaga revised this gist
May 5, 2015 . 1 changed file with 19 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -71,28 +71,28 @@ set :application, 'MyLittleApplication' set :application, -> { "SomeThing_#{fetch :other_config}" } ``` ``` fetch :application # => "MyLittleApplication" fetch(:special_thing, 'some_default_value') # will return the value if set, or the second argument as default value ``` ### 变量定义 - `:application` application 名称 - `:deploy_tp` 远端服务器部署的根目录。 `default: -> { "/var/www/#{fetch(:application)}" }` - `:scm` 所使用的版本管理系统。 `default: :git` - `:repo_url` 代码库的 url - `:repo_path` 远端服务器代码存放路径。 `default: -> { "#{fetch(:deploy_to)}/repo" }` - `:repo_tree` - `:linked_files` - `:linked_dirs` - `:default_env` - `:branch` - `:keep_releases` - `:tmp_dir` - `:local_user` - `:pty` - `:log_level` - `:format` -
zxzsaga renamed this gist
May 5, 2015 . 1 changed file with 36 additions and 36 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ 使用版本为 `capistrano 3.3.5` , Capistrano 安装方法自行 Google. ## 项目中初始化 Capistrano `cap install` 会生成如下目录文件: ``` ├── Capfile ├── config │ ├── deploy @@ -14,30 +14,30 @@ └── lib └── capistrano └── tasks ``` 其中, - `Capfile` 用来配置 Capistrano - `deploy.rb` 定义共用的 tasks - `production.rb/staging.rb` 定义具体的 stage 的 tasks ## 新建 stages `cap install STAGES=local,sandbox,qa,production` , `local,sandbox,qa,production` 等可以自行定义 ## 用法 - `cap -T` 列出所有 tasks - `cap staging deploy` 部署 staging 环境 - `cap production deploy` 部署 production 环境 - `cap production deploy --dry-run` 模拟部署 production 环境,但实际上不作任何操作 (?) - `cap production deploy --prereqs` 列出 task dependencies - `cap production deploy --trace` 跟踪 task 调用 (?) ## 服务器文件结构 在 `config/deploy.rb` 中可定义文件根目录: ``` set :deploy_to, '/var/www/my_app_name' ``` 那么部署之后, `/var/www/my_app_name` 的文件结构将会如下: ``` ├── current -> /var/www/my_app_name/releases/20150120114500/ ├── releases │ ├── 20150080072500 @@ -50,26 +50,26 @@ set :deploy_to, '/var/www/my_app_name' ├── revisions.log └── shared └── <linked_files and linked_dirs> ``` 其中, - `current` 是指向最新版本的指针 - `releases` 存放了所有版本的文件,并以时间戳命名。 `current` 指针指向这些目录中的一个。 - `repo` 存放版本管理系统的配置。如果是 Git 则会是一个完整的 git repository. - `revisions.log` 记录每次 deploy 或者 rollback. - `shared` (?) ## 配置 ### 配置文件 - 全局: `config/deploy.rb` - 针对特定 stage: `config/deploy/<stage_name>.rb` ### 变量存取 ``` set :application, 'MyLittleApplication' # use a lambda to delay evaluation set :application, -> { "SomeThing_#{fetch :other_config}" } ``` #+BEGIN_SRC fetch :application -
zxzsaga revised this gist
Mar 9, 2015 . 1 changed file with 67 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ 其中, - =Capfile= 用来配置 Capistrano - =deploy.rb= 定义共用的 tasks - =production.rb/staging.rb= 定义具体的 stage 的 tasks ** 新建 stages =cap install STAGES=local,sandbox,qa,production= , =local,sandbox,qa,production= 等可以自行定义 @@ -30,3 +30,69 @@ - =cap production deploy --dry-run= 模拟部署 production 环境,但实际上不作任何操作 (?) - =cap production deploy --prereqs= 列出 task dependencies - =cap production deploy --trace= 跟踪 task 调用 (?) ** 服务器文件结构 在 =config/deploy.rb= 中可定义文件根目录: #+BEGIN_SRC set :deploy_to, '/var/www/my_app_name' #+END_SRC 那么部署之后, =/var/www/my_app_name= 的文件结构将会如下: #+BEGIN_SRC ├── current -> /var/www/my_app_name/releases/20150120114500/ ├── releases │ ├── 20150080072500 │ ├── 20150090083000 │ ├── 20150100093500 │ ├── 20150110104000 │ └── 20150120114500 ├── repo │ └── <VCS related data> ├── revisions.log └── shared └── <linked_files and linked_dirs> #+END_SRC 其中, - =current= 是指向最新版本的指针 - =releases= 存放了所有版本的文件,并以时间戳命名。 =current= 指针指向这些目录中的一个。 - =repo= 存放版本管理系统的配置。如果是 Git 则会是一个完整的 git repository. - =revisions.log= 记录每次 deploy 或者 rollback. - =shared= (?) ** 配置 *** 配置文件 - 全局: =config/deploy.rb= - 针对特定 stage: =config/deploy/<stage_name>.rb= *** 变量存取 #+BEGIN_SRC set :application, 'MyLittleApplication' # use a lambda to delay evaluation set :application, -> { "SomeThing_#{fetch :other_config}" } #+END_SRC #+BEGIN_SRC fetch :application # => "MyLittleApplication" fetch(:special_thing, 'some_default_value') # will return the value if set, or the second argument as default value #+END_SRC *** 变量定义 - =:application= application 名称 - =:deploy_tp= 远端服务器部署的根目录。 =default: -> { "/var/www/#{fetch(:application)}" }= - =:scm= 所使用的版本管理系统。 =default: :git= - =:repo_url= 代码库的 url - =:repo_path= 远端服务器代码存放路径。 =default: -> { "#{fetch(:deploy_to)}/repo" }= - =:repo_tree= - =:linked_files= - =:linked_dirs= - =:default_env= - =:branch= - =:keep_releases= - =:tmp_dir= - =:local_user= - =:pty= - =:log_level= - =:format= -
zxzsaga revised this gist
Mar 9, 2015 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,5 +24,9 @@ =cap install STAGES=local,sandbox,qa,production= , =local,sandbox,qa,production= 等可以自行定义 ** 用法 - =cap -T= 列出所有 tasks - =cap staging deploy= 部署 staging 环境 - =cap production deploy= 部署 production 环境 - =cap production deploy --dry-run= 模拟部署 production 环境,但实际上不作任何操作 (?) - =cap production deploy --prereqs= 列出 task dependencies - =cap production deploy --trace= 跟踪 task 调用 (?) -
zxzsaga created this gist
Mar 9, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ 使用版本为 =capistrano 3.3.5= , Capistrano 安装方法自行 Google. ** 项目中初始化 Capistrano =cap install= 会生成如下目录文件: #+BEGIN_SRC ├── Capfile ├── config │ ├── deploy │ │ ├── production.rb │ │ └── staging.rb │ └── deploy.rb └── lib └── capistrano └── tasks #+END_SRC 其中, - =Capfile= 用来配置 Capistrano - =deploy.rb= 定义共用的 tasks - =production.rb/staging.rb= 定义具体的 stage 的 task ** 新建 stages =cap install STAGES=local,sandbox,qa,production= , =local,sandbox,qa,production= 等可以自行定义 ** 用法 - =cap -T= 列出所有 tasks