Skip to content

Commit

Permalink
v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Drewniak committed Sep 13, 2024
1 parent ae6ba21 commit 8b0f553
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
capistrano-data_plane_api (0.1.3)
capistrano-data_plane_api (0.1.4)
data_plane_api (~> 0.1)
pastel (< 1)
shale (>= 1, < 2)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ add this line to your `Capfile`
require 'capistrano/data_plane_api'
```

These tasks will only run when the `:web` role is added to the deployment stage.

## Hooks

If you used the installer, your app is already
Expand Down Expand Up @@ -188,6 +190,8 @@ deploy
data_plane_api:server:set_ready
```

These tasks will only run when the `:web` role is added to the deployment stage.

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down
22 changes: 14 additions & 8 deletions lib/capistrano/data_plane_api/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
namespace :server do
desc "Set the server's admin state to DRAIN through the HAProxy Data Plane API"
task :set_drain do
next if ::Capistrano::DataPlaneApi.no_haproxy?
on roles :web do
next if ::Capistrano::DataPlaneApi.no_haproxy?

::Capistrano::DataPlaneApi.server_set_drain fetch(:stage), force: ::Capistrano::DataPlaneApi.force_haproxy?
::Capistrano::DataPlaneApi.server_set_drain fetch(:stage), force: ::Capistrano::DataPlaneApi.force_haproxy?
end
end

desc "Set the server's admin state to READY through the HAProxy Data Plane API"
task :set_ready do
next if ::Capistrano::DataPlaneApi.no_haproxy?
on roles :web do
next if ::Capistrano::DataPlaneApi.no_haproxy?

sleep 3
::Capistrano::DataPlaneApi.server_set_ready fetch(:stage)
sleep 3
::Capistrano::DataPlaneApi.server_set_ready fetch(:stage)
end
end

desc "Set the server's admin state to MAINT through the HAProxy Data Plane API"
task :set_maint do
next if ::Capistrano::DataPlaneApi.no_haproxy?
on roles :web do
next if ::Capistrano::DataPlaneApi.no_haproxy?

sleep 3
::Capistrano::DataPlaneApi.server_set_maint fetch(:stage), force: true
sleep 3
::Capistrano::DataPlaneApi.server_set_maint fetch(:stage), force: true
end
end
end
end
2 changes: 1 addition & 1 deletion lib/capistrano/data_plane_api/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
module Capistrano
module DataPlaneApi
# @return [String]
VERSION = '0.1.3'
VERSION = '0.1.4'
end
end

0 comments on commit 8b0f553

Please sign in to comment.