capistrano-karafka 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +6 -0
- data/MIT-LICENCE +18 -0
- data/README.md +61 -0
- data/Rakefile +3 -0
- data/capistrano-karafka.gemspec +27 -0
- data/lib/capistrano-karafka.rb +1 -0
- data/lib/capistrano/karafka.rb +28 -0
- data/lib/capistrano/karafka/version.rb +8 -0
- data/lib/capistrano/tasks/karafka.cap +72 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 369db3566eeacd1e9a68a38f222fadd990856a74
|
4
|
+
data.tar.gz: 294d4ac5bf51d1d87a760b6547335c300a3686b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2033aa8fa0476cf716c31a2917ff2ab7e32b4d33cd7b959e0abd4a6c1feb345e71eda6221a761484709da52a2332beda6cd52e5a367165344d482cf4e368c120
|
7
|
+
data.tar.gz: 5741accff7643074cf38f844df021f0368e1ae622c49fc378dda8e7ebd06b36f8b357451632bff500d5cfdd4168fb6c782697c85c49f8b46cf136b94315f5a7e
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
capistrano-karafka
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/MIT-LICENCE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
2
|
+
a copy of this software and associated documentation files (the
|
3
|
+
"Software"), to deal in the Software without restriction, including
|
4
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
5
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
6
|
+
permit persons to whom the Software is furnished to do so, subject to
|
7
|
+
the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be
|
10
|
+
included in all copies or substantial portions of the Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
13
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
14
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
15
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
16
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
17
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
18
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Capistrano Karafka
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/capistrano-karafka)
|
4
|
+
[](https://gitter.im/karafka/karafka?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
|
+
|
6
|
+
Karafka integration for Capistrano.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'capistrano-karafka'
|
14
|
+
```
|
15
|
+
|
16
|
+
or:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'capistrano-karafka' , group: :development
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
```
|
25
|
+
$ bundle
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
In your **Capfile**
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'capistrano/karafka'
|
34
|
+
install_plugin Capistrano::Karafka
|
35
|
+
```
|
36
|
+
|
37
|
+
Take a look at the [set_defaults](https://github.com/karafka/capistrano-karafka/blob/master/lib/capistrano/karafka.rb#L16) method for options you can set. For example, to specify a different pidfile than default:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
set :karafka_pid, ->{ File.join(shared_path, 'tmp', 'pids', 'karafka0') }
|
41
|
+
```
|
42
|
+
|
43
|
+
## References
|
44
|
+
|
45
|
+
* [Karafka framework](https://github.com/karafka/karafka)
|
46
|
+
* [Capistrano Karafka](https://github.com/karafka/capistrano-karafka)
|
47
|
+
* [Waterdrop](https://github.com/karafka/waterdrop)
|
48
|
+
* [Envlogic](https://github.com/karafka/envlogic)
|
49
|
+
* [Worker Glass](https://github.com/karafka/worker-glass)
|
50
|
+
* [Null Logger](https://github.com/karafka/null-logger)
|
51
|
+
|
52
|
+
## Note on Patches/Pull Requests
|
53
|
+
|
54
|
+
Fork the project.
|
55
|
+
Make your feature addition or bug fix.
|
56
|
+
Add tests for it. This is important so I don't break it in a future version unintentionally.
|
57
|
+
Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull). Send me a pull request. Bonus points for topic branches.
|
58
|
+
|
59
|
+
[](https://coditsu.io)
|
60
|
+
|
61
|
+
Each pull request must pass our quality requirements. To check if everything is as it should be, we use [Coditsu](https://coditsu.io) that combinse multiple linters and code analyzers. Unfortunately, for now it is invite-only based, so just ping us and we will give you access to the quality results.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'capistrano/karafka/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'capistrano-karafka'
|
10
|
+
spec.version = Capistrano::Karafka::VERSION
|
11
|
+
spec.platform = Gem::Platform::RUBY
|
12
|
+
spec.authors = ['Maciej Mensfeld']
|
13
|
+
spec.email = %w[maciej@coditsu.io]
|
14
|
+
spec.homepage = 'https://github.com/karafka/capistrano-karafka'
|
15
|
+
spec.summary = 'Karafka integration for Capistrano'
|
16
|
+
spec.description = 'Karafka integration for Capistrano'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.add_dependency 'capistrano', '~> 3.8'
|
20
|
+
spec.add_dependency 'capistrano-bundler'
|
21
|
+
spec.add_dependency 'karafka', '~> 0'
|
22
|
+
spec.required_ruby_version = '>= 2.3.0'
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
25
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = %w[lib]
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# frozen_string_literal: true
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'capistrano/bundler'
|
4
|
+
require 'capistrano/plugin'
|
5
|
+
|
6
|
+
# Capistrano stuff
|
7
|
+
module Capistrano
|
8
|
+
# Karafka Capistrano integration
|
9
|
+
class Karafka < Capistrano::Plugin
|
10
|
+
# Defines all the capistrano tasks by taking them from the rake cap file
|
11
|
+
def define_tasks
|
12
|
+
eval_rakefile File.expand_path('../tasks/karafka.cap', __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Default values for Karafka settings
|
16
|
+
def set_defaults
|
17
|
+
set_if_empty :karafka_role, :app
|
18
|
+
set_if_empty :karafka_default_hooks, -> { true }
|
19
|
+
set_if_empty :karafka_env, -> { fetch(:karafka_env, fetch(:environment)) }
|
20
|
+
set_if_empty :karafka_pid, -> { File.join(shared_path, 'tmp', 'pids', 'karafka.pid') }
|
21
|
+
end
|
22
|
+
|
23
|
+
# Deploy hooks registration
|
24
|
+
def register_hooks
|
25
|
+
after 'deploy:finished', 'karafka:restart'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# @note Inspired by Puma capistrano handlers
|
4
|
+
# @see https://github.com/seuros/capistrano-puma/blob/master/lib/capistrano/tasks/puma.rake
|
5
|
+
namespace :karafka do
|
6
|
+
desc 'Stop Karafka'
|
7
|
+
task :stop do
|
8
|
+
on roles(fetch(:karafka_role)) do |_host|
|
9
|
+
within shared_path do
|
10
|
+
# If there's no pidfile it means that Karafka is not running
|
11
|
+
next unless test "cat #{fetch(:karafka_pid)}"
|
12
|
+
|
13
|
+
# Send a kill signal to a given process
|
14
|
+
execute "kill -INT `cat #{fetch(:karafka_pid)}`"
|
15
|
+
|
16
|
+
# And wait until it finishes. We wait because we don't want to start next process until
|
17
|
+
# the previous one is stopped. That way we won't have problems with Kafka registering and
|
18
|
+
# deregistering processes from topics (although nothing bad would happen. It would just
|
19
|
+
# take more time to rebalance)
|
20
|
+
loop do
|
21
|
+
break unless test "cat #{fetch(:karafka_pid)}"
|
22
|
+
info 'Waiting for Karafka to stop'
|
23
|
+
sleep 5
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Start Karafka'
|
30
|
+
task :start do
|
31
|
+
on roles(fetch(:karafka_role)) do |_host|
|
32
|
+
within current_path do
|
33
|
+
# We use all 3 because when combined with Sinatra/Rails it will use their parts as well
|
34
|
+
# so we want to set proper env for any of them
|
35
|
+
with(
|
36
|
+
KARAFKA_ENV: fetch(:karafka_env),
|
37
|
+
RAILS_ENV: fetch(:rails_env),
|
38
|
+
RACK_ENV: fetch(:rack_env)
|
39
|
+
) do
|
40
|
+
execute :bundle, "exec karafka server -d -p #{fetch(:karafka_pid)}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'Restart Karafka'
|
47
|
+
task :restart do
|
48
|
+
invoke 'karafka:stop'
|
49
|
+
invoke 'karafka:start'
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'Status Karafka'
|
53
|
+
task :status do
|
54
|
+
on roles(fetch(:karafka_role)) do |_host|
|
55
|
+
if test "cat #{fetch(:karafka_pid)}"
|
56
|
+
pid = capture "cat #{fetch(:karafka_pid)}"
|
57
|
+
|
58
|
+
if test "ps -p #{pid} > /dev/null"
|
59
|
+
info "Karafka is started: #{pid}"
|
60
|
+
else
|
61
|
+
error 'Karafka is not started but pidfile exists'
|
62
|
+
end
|
63
|
+
else
|
64
|
+
info 'Karafka is not started'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
task :add_default_hooks do
|
70
|
+
after 'deploy:finished', 'karafka:restart'
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-karafka
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maciej Mensfeld
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: capistrano-bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: karafka
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Karafka integration for Capistrano
|
56
|
+
email:
|
57
|
+
- maciej@coditsu.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".ruby-gemset"
|
64
|
+
- ".ruby-version"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- Gemfile
|
67
|
+
- MIT-LICENCE
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- capistrano-karafka.gemspec
|
71
|
+
- lib/capistrano-karafka.rb
|
72
|
+
- lib/capistrano/karafka.rb
|
73
|
+
- lib/capistrano/karafka/version.rb
|
74
|
+
- lib/capistrano/tasks/karafka.cap
|
75
|
+
homepage: https://github.com/karafka/capistrano-karafka
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 2.3.0
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.6.11
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Karafka integration for Capistrano
|
99
|
+
test_files: []
|