Skip to content

Instantly share code, notes, and snippets.

@zxzsaga
Last active April 27, 2021 07:48
Show Gist options
  • Select an option

  • Save zxzsaga/7bd05b5f22f6f367efdd to your computer and use it in GitHub Desktop.

Select an option

Save zxzsaga/7bd05b5f22f6f367efdd to your computer and use it in GitHub Desktop.
Capistrano 使用

使用版本为 capistrano 3.3.5 , Capistrano 安装方法自行 Google.

项目中初始化 Capistrano

cap install

会生成如下目录文件:

├── Capfile   
├── config   
│   ├── deploy   
│   │   ├── production.rb   
│   │   └── staging.rb   
│   └── deploy.rb   
└── lib   
    └── capistrano   
        └── tasks

其中,

  • 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
  • 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 调用 (?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment