使用 SSH Kit 执行远程命令

Capistrano 使用 SSHKit 在远程服务器上执行命令。

设置工作目录、用户和环境变量的示例

on roles(:app), in: :sequence, wait: 5 do
  within "/opt/sites/example.com" do
    # commands in this block execute in the
    # directory: /opt/sites/example.com
    as :deploy do
      # commands in this block execute as the "deploy" user.
      with rails_env: :production do
        # commands in this block execute with the environment
        # variable RAILS_ENV=production
        rake   "assets:precompile"
        runner "S3::Sync.notify"
      end
    end
  end
end

有关更多示例,请参阅 SSHKit 项目中的 EXAMPLES.md 文件

https://github.com/capistrano/sshkit/blob/master/EXAMPLES.md

Fork me on GitHub