Deploy lock feature for Capistrano 3.4.x
Lock deploy when deployment is running or custom lock to prevent further deployment for Capistrano 3.
Add this line to your application's Gemfile:
gem 'capistrano-deploy-lock', '~> 1.0'
gem 'capistrano'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install capistrano-deploy-lock
Require in Capfile
to use the default task:
require 'capistrano/deploy-lock'
Deploy with default configuration:
Just run normal capistrano command, deploy lock will work automatically.
$ cap production deploy
You will get the following tasks
cap production deploy:with_lock # Deploy with custom lock
cap production deploy:lock # Lock manually (without deploy)
cap production deploy:unlock # Unlock manually
cap production deploy:unlock:force # Unlock forcefully
Configurable options (copy into deploy.rb), shown here with examples:
# Deploy Lock File
# default value: File.join(shared_path, "deploy-lock.yml")
set :deploy_lock_file, -> { File.join(shared_path, "deploy-lock.yml") }
# Deploy Lock Roles
# default value: :app ; use array for multiple roles
set :deploy_lock_roles, -> { :app }
# Deploy lock expiry (in second)
# Default 15 minutes
set :default_lock_expiry, (15 * 60)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
cap-deploy-lock is maintained by Maruf Hasan Bulbul.
© 2016 Maruf Hasan Bulbul. It is free software and may be redistributed.