deploy_pin 1.2.2 → 1.3.1
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 +4 -4
- data/README.md +1 -1
- data/Rakefile +3 -23
- data/app/models/deploy_pin/application_record.rb +2 -0
- data/app/models/deploy_pin/record.rb +0 -1
- data/lib/deploy_pin/collector.rb +13 -2
- data/lib/deploy_pin/database.rb +91 -0
- data/lib/deploy_pin/engine.rb +2 -0
- data/lib/deploy_pin/parallel_wrapper.rb +95 -0
- data/lib/deploy_pin/runner.rb +6 -6
- data/lib/deploy_pin/task.rb +30 -13
- data/lib/deploy_pin/task_criteria.rb +5 -5
- data/lib/deploy_pin/version.rb +3 -1
- data/lib/deploy_pin.rb +16 -11
- data/lib/generators/deploy_pin/install/install_generator.rb +5 -3
- data/lib/generators/deploy_pin/install/templates/create_deploy_pins.rb +2 -0
- data/lib/generators/deploy_pin/install/templates/deploy_pin.rb +5 -3
- data/lib/generators/deploy_pin/task/templates/parallel_task.rb.erb +8 -0
- data/lib/generators/deploy_pin/task/templates/task.rb.erb +8 -0
- data/lib/tasks/deploy_pin_tasks.rake +7 -5
- metadata +45 -69
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f3006ccc3913b4cc7ee0b5d68b316ffb70ecef2bbfeae27c7efec65422246cdb
|
|
4
|
+
data.tar.gz: d055a8554b590bc039915d3a2866f23aa8541db9ffe8c2c933294f54c2013785
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 70d4054142995c62609666711a87d4d4e42783bf4631e61f3a43e3407a9cd68654de65b0925655ca416fb65e41bccd3a2246125e446f5f4d8a9cb48f70e7ffd4
|
|
7
|
+
data.tar.gz: 654cbb997e23bf9a2cc9d8579e71646f68fd669dfd92235da2a1d15b8b3d9775b01db714ce99e79e23e6389282a907c2f9ae5b573c348bd4b0d3f43105989903
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[](https://badge.fury.io/rb/deploy_pin)
|
|
2
2
|

|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
[](https://codeclimate.com/github/skcc321/deploy_pin/maintainability)
|
|
5
5
|
[](https://codeclimate.com/github/skcc321/deploy_pin/test_coverage)
|
|
6
6
|
|
data/Rakefile
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
require 'bundler/setup'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
6
2
|
|
|
7
|
-
require '
|
|
8
|
-
|
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
-
rdoc.title = 'DeployPin'
|
|
12
|
-
rdoc.options << '--line-numbers'
|
|
13
|
-
rdoc.rdoc_files.include('README.md')
|
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
-
end
|
|
3
|
+
require 'bundler/setup'
|
|
16
4
|
|
|
17
5
|
require 'bundler/gem_tasks'
|
|
18
6
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Rake::TestTask.new(:test) do |t|
|
|
22
|
-
t.libs << 'test'
|
|
23
|
-
t.pattern = 'test/**/*_test.rb'
|
|
24
|
-
t.verbose = false
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
task default: :test
|
|
7
|
+
import 'test/dummy/Rakefile'
|
data/lib/deploy_pin/collector.rb
CHANGED
|
@@ -19,7 +19,11 @@ module DeployPin
|
|
|
19
19
|
yield(index, _tasks.count, task, executable)
|
|
20
20
|
|
|
21
21
|
# run if executable
|
|
22
|
-
|
|
22
|
+
if executable
|
|
23
|
+
run_with_timeout(!task.explicit_timeout? && !task.parallel?) do
|
|
24
|
+
task.run
|
|
25
|
+
end
|
|
26
|
+
end
|
|
23
27
|
|
|
24
28
|
# mark each task as done
|
|
25
29
|
task.mark unless task.done?
|
|
@@ -46,7 +50,7 @@ module DeployPin
|
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
private
|
|
49
|
-
|
|
53
|
+
# :reek:UtilityFunction
|
|
50
54
|
def files
|
|
51
55
|
Dir["#{DeployPin.tasks_path}/*.rb"]
|
|
52
56
|
end
|
|
@@ -64,5 +68,12 @@ module DeployPin
|
|
|
64
68
|
def task_criteria
|
|
65
69
|
@task_criteria ||= DeployPin::TaskCriteria.new(identifiers: identifiers)
|
|
66
70
|
end
|
|
71
|
+
|
|
72
|
+
# :reek:UtilityFunction and :reek:ControlParameter
|
|
73
|
+
def run_with_timeout(under_timeout, &block)
|
|
74
|
+
return yield unless under_timeout
|
|
75
|
+
|
|
76
|
+
DeployPin::Database.execute_with_timeout(DeployPin.statement_timeout, **{}, &block)
|
|
77
|
+
end
|
|
67
78
|
end
|
|
68
79
|
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module DeployPin
|
|
4
|
+
module Database
|
|
5
|
+
PG_TIMEOUT_STATEMENT = 'SET statement_timeout TO %s'
|
|
6
|
+
MYSQL_TIMEOUT_STATEMENT = 'SET max_execution_time = %s'
|
|
7
|
+
|
|
8
|
+
extend self
|
|
9
|
+
|
|
10
|
+
# Run a block under a sql maximum timeout.
|
|
11
|
+
#
|
|
12
|
+
# A default timeout will be get from DeployPin.setup
|
|
13
|
+
#
|
|
14
|
+
# # config/initializers/deploy_pin.rb
|
|
15
|
+
# DeployPin.setup do
|
|
16
|
+
# statement_timeout 0.2.second # 200 ms
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# # <app root>/deploy_pin/20190401135040_task.rb
|
|
20
|
+
# # 20190401135040:I
|
|
21
|
+
# # task_title: Execute some query with timeout
|
|
22
|
+
#
|
|
23
|
+
# # === task code goes down here ===
|
|
24
|
+
# DeployPin::Database::execute_with_timeout do
|
|
25
|
+
# ActiveRecord::Base.connection.execute("select * from shipments;")
|
|
26
|
+
# end
|
|
27
|
+
#
|
|
28
|
+
# A timeout can be passed as param as well:
|
|
29
|
+
#
|
|
30
|
+
# DeployPin::Database::execute_with_timeout 10.minutes do
|
|
31
|
+
# ActiveRecord::Base.connection.execute("select * from shipments;")
|
|
32
|
+
# end
|
|
33
|
+
#
|
|
34
|
+
# In order to connect to multiple databases, pass the +connected_to+ keyword into the params.
|
|
35
|
+
# The +connected_to+ will use the +ActiveRecord::Base.connected_to+.
|
|
36
|
+
# To connect to a replica database, for example:
|
|
37
|
+
#
|
|
38
|
+
# DeployPin::Database::execute_with_timeout 1.seconds, connected_to: { role: :reading } do
|
|
39
|
+
# Shipment.all # Get all record from replica
|
|
40
|
+
# end
|
|
41
|
+
#
|
|
42
|
+
# Or a specific database:
|
|
43
|
+
#
|
|
44
|
+
# DeployPin::Database.execute_with_timeout 30.second, connected_to: { database: :test_mysql } do
|
|
45
|
+
# ActiveRecord::Base.connection.execute("<some mysql query>")
|
|
46
|
+
# end
|
|
47
|
+
def execute_with_timeout(timeout = DeployPin.statement_timeout, **params, &blk)
|
|
48
|
+
raise ArgumentError, 'timeout must be greater than zero' if timeout.to_f <= 0
|
|
49
|
+
|
|
50
|
+
return call_block_under_timeout(timeout, &blk) unless params.key? :connected_to
|
|
51
|
+
|
|
52
|
+
klass = params[:connected_to].key?(:database) ? ActiveRecord::Base : ::ApplicationRecord
|
|
53
|
+
klass.connected_to(**params[:connected_to]) do
|
|
54
|
+
call_block_under_timeout(timeout, &blk)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def call_block_under_timeout(timeout)
|
|
61
|
+
set_max_timeout(timeout)
|
|
62
|
+
|
|
63
|
+
yield
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def set_max_timeout(timeout)
|
|
67
|
+
timeout_in_milliseconds = timeout.to_f.in_milliseconds.ceil # Make sure is always at least 1. 0 turns this off
|
|
68
|
+
|
|
69
|
+
timeout_statement =
|
|
70
|
+
if postgresql?
|
|
71
|
+
PG_TIMEOUT_STATEMENT
|
|
72
|
+
elsif mysql?
|
|
73
|
+
MYSQL_TIMEOUT_STATEMENT
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
connection.execute timeout_statement % connection.quote(timeout_in_milliseconds)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def postgresql?
|
|
80
|
+
connection.adapter_name =~ /postg/i
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def mysql?
|
|
84
|
+
connection.adapter_name =~ /mysql/i
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def connection
|
|
88
|
+
ActiveRecord::Base.connection
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
data/lib/deploy_pin/engine.rb
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module DeployPin
|
|
4
|
+
# Parallel wrapper to run parallel tasks using database statement timeout.
|
|
5
|
+
# This wrapper keeps parallel interface, but running the processes under db statement timeout.
|
|
6
|
+
#
|
|
7
|
+
# In order to use this wrapper, just use call parallel methods with `parallel_`. Ex.:
|
|
8
|
+
# parallel_each(1..2, in_processes: 2, timeout: 0.3.seconds) do |i|
|
|
9
|
+
# puts "Item: #{i}, Worker: #{Parallel.worker_number}"
|
|
10
|
+
# ActiveRecord::Base.connection.execute("<some db query>")
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
# In order to pass more `timeout` options, it requires to pass an array, like:
|
|
14
|
+
# parallel_each(1..2, in_processes: 2, timeout: [0.3.seconds, { connected_to: { role: :reading } }]) do |i|
|
|
15
|
+
# puts "Item: #{i}, Worker: #{Parallel.worker_number}"
|
|
16
|
+
# ActiveRecord::Base.connection.execute("<some db query>")
|
|
17
|
+
# end
|
|
18
|
+
module ParallelWrapper
|
|
19
|
+
PARALLEL_PREFIX = 'parallel_'
|
|
20
|
+
|
|
21
|
+
# :reek:TooManyInstanceVariables
|
|
22
|
+
class ParallelRunner
|
|
23
|
+
def initialize(method_name, *args, &db_block)
|
|
24
|
+
@method_name = method_name
|
|
25
|
+
@db_block = db_block
|
|
26
|
+
|
|
27
|
+
if args.last.is_a?(Hash) && args.last.key?(:timeout)
|
|
28
|
+
@timeout_args = args.pop
|
|
29
|
+
prepare_timeout_args
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
@parallel_args = args
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def run
|
|
36
|
+
raise 'You must provide at least one argument for parallel methods' if parallel_args.empty?
|
|
37
|
+
|
|
38
|
+
Parallel.send(parallel_method_name, *parallel_args) do |*block_args|
|
|
39
|
+
ActiveRecord::Base.connection_pool.with_connection do
|
|
40
|
+
DeployPin::Database.execute_with_timeout(timeout, **timeout_params) do
|
|
41
|
+
db_block.call(*block_args)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
attr_accessor :method_name, :parallel_args, :db_block
|
|
50
|
+
|
|
51
|
+
def prepare_timeout_args
|
|
52
|
+
timeout = @timeout_args[:timeout]
|
|
53
|
+
if timeout.is_a?(Array)
|
|
54
|
+
@timeout = timeout.shift
|
|
55
|
+
@timeout_params = timeout.first
|
|
56
|
+
else
|
|
57
|
+
@timeout = timeout
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def timeout
|
|
62
|
+
@timeout ||= DeployPin.statement_timeout
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def timeout_params
|
|
66
|
+
@timeout_params ||= {}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def parallel_method_name
|
|
70
|
+
@parallel_method_name ||= method_name.to_s.gsub(PARALLEL_PREFIX, '').to_sym
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def method_missing(name, *args, &block)
|
|
75
|
+
return super unless respond_to_missing?(name)
|
|
76
|
+
|
|
77
|
+
ParallelRunner.new(name, *args, &block).run
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# :reek:ManualDispatch and :reek:BooleanParameter
|
|
81
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
82
|
+
return super unless parallel_prefix_pattern.match? method_name
|
|
83
|
+
|
|
84
|
+
parallel_method_name = method_name.to_s.gsub(PARALLEL_PREFIX, '').to_sym
|
|
85
|
+
|
|
86
|
+
Parallel.respond_to?(parallel_method_name) || super
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
private
|
|
90
|
+
|
|
91
|
+
def parallel_prefix_pattern
|
|
92
|
+
@parallel_prefix_pattern ||= /\A#{PARALLEL_PREFIX}/
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
data/lib/deploy_pin/runner.rb
CHANGED
|
@@ -10,7 +10,7 @@ module DeployPin
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def self.list(identifiers:)
|
|
13
|
-
DeployPin::Collector.new(identifiers: identifiers).list do |index,
|
|
13
|
+
DeployPin::Collector.new(identifiers: identifiers).list do |index, _count, task|
|
|
14
14
|
self.print("======= Task ##{index} ========".white)
|
|
15
15
|
|
|
16
16
|
# print details
|
|
@@ -18,17 +18,17 @@ module DeployPin
|
|
|
18
18
|
self.print("#{key}:\t\t#{value}")
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
self.print(
|
|
22
|
-
self.print(
|
|
21
|
+
self.print('')
|
|
22
|
+
self.print('<<<')
|
|
23
23
|
self.print task.script.strip.green
|
|
24
|
-
self.print(
|
|
25
|
-
self.print(
|
|
24
|
+
self.print('>>>')
|
|
25
|
+
self.print('')
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def self.summary(identifiers:)
|
|
30
30
|
# print summary
|
|
31
|
-
self.print(
|
|
31
|
+
self.print('======= Summary ========')
|
|
32
32
|
self.print("tasks number: #{DeployPin::Collector.new(identifiers: identifiers).tasks_count}")
|
|
33
33
|
end
|
|
34
34
|
|
data/lib/deploy_pin/task.rb
CHANGED
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
# Task wrapper
|
|
4
4
|
module DeployPin
|
|
5
5
|
class Task
|
|
6
|
+
extend ::DeployPin::ParallelWrapper
|
|
7
|
+
include ::DeployPin::ParallelWrapper
|
|
8
|
+
|
|
6
9
|
attr_reader :file,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
:uuid,
|
|
11
|
+
:group,
|
|
12
|
+
:title,
|
|
13
|
+
:script,
|
|
14
|
+
:explicit_timeout
|
|
11
15
|
|
|
12
16
|
def initialize(file)
|
|
13
17
|
@file = file
|
|
14
18
|
@uuid = nil
|
|
15
19
|
@group = nil
|
|
16
|
-
@title =
|
|
17
|
-
@script =
|
|
20
|
+
@title = ''
|
|
21
|
+
@script = ''
|
|
22
|
+
@explicit_timeout = false
|
|
23
|
+
@parallel = false
|
|
18
24
|
end
|
|
19
25
|
|
|
20
26
|
def run
|
|
@@ -31,16 +37,27 @@ module DeployPin
|
|
|
31
37
|
DeployPin::Record.where(uuid: uuid).exists?
|
|
32
38
|
end
|
|
33
39
|
|
|
40
|
+
def explicit_timeout?
|
|
41
|
+
@explicit_timeout
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def parallel?
|
|
45
|
+
@parallel
|
|
46
|
+
end
|
|
47
|
+
|
|
34
48
|
def parse_file
|
|
35
49
|
File.foreach(file) do |line|
|
|
36
50
|
case line.strip
|
|
37
51
|
when /\A# (\d+):(\w+)/
|
|
38
|
-
@uuid =
|
|
39
|
-
@group =
|
|
52
|
+
@uuid = Regexp.last_match(1)
|
|
53
|
+
@group = Regexp.last_match(2)
|
|
40
54
|
when /\A# task_title:(.+)/
|
|
41
|
-
@title =
|
|
55
|
+
@title = Regexp.last_match(1).strip
|
|
42
56
|
when /\A[^#].*/
|
|
43
57
|
@script += line
|
|
58
|
+
|
|
59
|
+
@explicit_timeout = true if line =~ /Database.execute_with_timeout.*/
|
|
60
|
+
@parallel = true if line =~ /[Pp]arallel.*/
|
|
44
61
|
end
|
|
45
62
|
end
|
|
46
63
|
end
|
|
@@ -53,16 +70,16 @@ module DeployPin
|
|
|
53
70
|
}
|
|
54
71
|
end
|
|
55
72
|
|
|
56
|
-
def eql?(
|
|
73
|
+
def eql?(other)
|
|
57
74
|
# same script & different uuid
|
|
58
|
-
script ==
|
|
75
|
+
script == other.script && uuid != other.uuid
|
|
59
76
|
end
|
|
60
77
|
|
|
61
78
|
protected
|
|
62
79
|
|
|
63
80
|
# for sorting
|
|
64
|
-
def <=>(
|
|
65
|
-
group_index <=>
|
|
81
|
+
def <=>(other)
|
|
82
|
+
group_index <=> other.group_index
|
|
66
83
|
end
|
|
67
84
|
|
|
68
85
|
def group_index
|
|
@@ -14,16 +14,16 @@ module DeployPin
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def suitable?(task)
|
|
17
|
-
task_cover =
|
|
18
|
-
items = identifiers.flat_map {|x| x.to_s.scan(regexp) }.flatten
|
|
17
|
+
task_cover = lambda { |task, regexp|
|
|
18
|
+
items = identifiers.flat_map { |x| x.to_s.scan(regexp) }.flatten
|
|
19
19
|
|
|
20
20
|
items & [task.group, task.uuid]
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
return false if task_cover.(task, SKIP_REGEXEP).any?
|
|
24
|
-
return true if task_cover.(task, FORCE_REGEXP).any?
|
|
23
|
+
return false if task_cover.call(task, SKIP_REGEXEP).any?
|
|
24
|
+
return true if task_cover.call(task, FORCE_REGEXP).any?
|
|
25
25
|
|
|
26
|
-
task_cover.(task, COMMON_REGEXP).any? && !task.done?
|
|
26
|
+
task_cover.call(task, COMMON_REGEXP).any? && !task.done?
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
data/lib/deploy_pin/version.rb
CHANGED
data/lib/deploy_pin.rb
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'deploy_pin/runner'
|
|
4
|
+
require 'deploy_pin/collector'
|
|
5
|
+
require 'deploy_pin/parallel_wrapper'
|
|
6
|
+
require 'deploy_pin/task'
|
|
7
|
+
require 'deploy_pin/task_criteria'
|
|
8
|
+
require 'deploy_pin/engine'
|
|
9
|
+
require 'deploy_pin/database'
|
|
10
|
+
require 'parallel'
|
|
11
|
+
require 'ruby-progressbar'
|
|
12
|
+
require 'colorize'
|
|
9
13
|
|
|
10
14
|
module DeployPin
|
|
11
|
-
OPTIONS = %i
|
|
15
|
+
OPTIONS = %i[
|
|
12
16
|
tasks_path
|
|
13
17
|
fallback_group
|
|
14
18
|
groups
|
|
15
|
-
|
|
19
|
+
statement_timeout
|
|
20
|
+
].freeze
|
|
16
21
|
|
|
17
22
|
OPTIONS.each do |option|
|
|
18
23
|
instance_eval %{
|
|
@@ -21,7 +26,7 @@ module DeployPin
|
|
|
21
26
|
|
|
22
27
|
@@#{option} = val
|
|
23
28
|
end
|
|
24
|
-
}
|
|
29
|
+
}, __FILE__, __LINE__ - 6
|
|
25
30
|
end
|
|
26
31
|
|
|
27
32
|
def self.setup(&block)
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class DeployPin::InstallGenerator < Rails::Generators::Base
|
|
2
4
|
include Rails::Generators::Migration
|
|
3
5
|
|
|
4
6
|
source_root File.expand_path('templates', __dir__)
|
|
5
|
-
desc
|
|
7
|
+
desc 'Add the migration & initializer for DeployPin'
|
|
6
8
|
|
|
7
9
|
def self.next_migration_number(path)
|
|
8
10
|
next_migration_number = current_migration_number(path) + 1
|
|
@@ -10,10 +12,10 @@ class DeployPin::InstallGenerator < Rails::Generators::Base
|
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def copy_migrations
|
|
13
|
-
migration_template
|
|
15
|
+
migration_template 'create_deploy_pins.rb', 'db/migrate/create_deploy_pins.rb'
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def copy_initializer
|
|
17
|
-
template
|
|
19
|
+
template 'deploy_pin.rb', 'config/initializers/deploy_pin.rb'
|
|
18
20
|
end
|
|
19
21
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# <%= @uuid %>:<%= group %>
|
|
2
4
|
# task_title: super duper task
|
|
3
5
|
|
|
@@ -9,4 +11,10 @@ Parallel.each(DeployPin::Record.where(uuid: "hello"), progress: "Doing stuff") d
|
|
|
9
11
|
pin.update_attribute(:uuid, "new uuid")
|
|
10
12
|
end
|
|
11
13
|
sleep(0.2)
|
|
14
|
+
|
|
15
|
+
# DeployPin::Database::execute_with_timeout 10.minutes do
|
|
16
|
+
# ActiveRecord::Base.connection.execute("select * from shipments;")
|
|
17
|
+
# or
|
|
18
|
+
# Shipment.all
|
|
19
|
+
# end
|
|
12
20
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# <%= @uuid %>:<%= group %>
|
|
2
4
|
# task_title: super duper task
|
|
3
5
|
|
|
@@ -5,3 +7,9 @@
|
|
|
5
7
|
progressbar = ProgressBar.create(title: "Doing stuff", total: 20, format: '%t |%E | %B | %a')
|
|
6
8
|
|
|
7
9
|
20.times { progressbar.increment; sleep(0.2) }
|
|
10
|
+
|
|
11
|
+
# DeployPin::Database::execute_with_timeout 10.minutes do
|
|
12
|
+
# ActiveRecord::Base.connection.execute("select * from shipments;")
|
|
13
|
+
# or
|
|
14
|
+
# Shipment.all
|
|
15
|
+
# end
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
namespace :deploy_pin do
|
|
2
|
-
desc
|
|
3
|
-
task :run, [:identifiers] => :environment do |
|
|
4
|
+
desc 'run pending tasks'
|
|
5
|
+
task :run, [:identifiers] => :environment do |_t, args|
|
|
4
6
|
identifiers = args.identifiers
|
|
5
7
|
attributes = identifiers.nil? ? DeployPin.groups : identifiers.split(/\s*,\s*/)
|
|
6
8
|
|
|
7
9
|
DeployPin::Runner.run(identifiers: attributes)
|
|
8
10
|
end
|
|
9
11
|
|
|
10
|
-
task :list, [:identifiers] => :environment
|
|
12
|
+
task :list, [:identifiers] => :environment do |_t, args|
|
|
11
13
|
args.with_defaults(identifiers: DeployPin.groups)
|
|
12
14
|
|
|
13
|
-
DeployPin::Runner.list(args)
|
|
14
|
-
DeployPin::Runner.summary(args)
|
|
15
|
+
DeployPin::Runner.list(**args)
|
|
16
|
+
DeployPin::Runner.summary(**args)
|
|
15
17
|
end
|
|
16
18
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deploy_pin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
autorequire:
|
|
7
|
+
- Viktor Sych
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-08-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: colorize
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: parallel
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,47 +39,41 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '1.16'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rails
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 6.0.1
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 6.0.1
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: ruby-progressbar
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
62
|
-
- - ">="
|
|
63
|
-
- !ruby/object:Gem::Version
|
|
64
|
-
version: 12.3.2
|
|
61
|
+
version: '1.10'
|
|
65
62
|
type: :runtime
|
|
66
63
|
prerelease: false
|
|
67
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
68
65
|
requirements:
|
|
69
66
|
- - "~>"
|
|
70
67
|
- !ruby/object:Gem::Version
|
|
71
|
-
version: '
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: 12.3.2
|
|
68
|
+
version: '1.10'
|
|
75
69
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
70
|
+
name: bundler
|
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
|
78
72
|
requirements:
|
|
79
73
|
- - ">="
|
|
80
74
|
- !ruby/object:Gem::Version
|
|
81
75
|
version: '0'
|
|
82
|
-
type: :
|
|
76
|
+
type: :development
|
|
83
77
|
prerelease: false
|
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
79
|
requirements:
|
|
@@ -87,95 +81,75 @@ dependencies:
|
|
|
87
81
|
- !ruby/object:Gem::Version
|
|
88
82
|
version: '0'
|
|
89
83
|
- !ruby/object:Gem::Dependency
|
|
90
|
-
name:
|
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - "~>"
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.16.0
|
|
96
|
-
type: :development
|
|
97
|
-
prerelease: false
|
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - "~>"
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: 0.16.0
|
|
103
|
-
- !ruby/object:Gem::Dependency
|
|
104
|
-
name: bundler
|
|
84
|
+
name: minitest
|
|
105
85
|
requirement: !ruby/object:Gem::Requirement
|
|
106
86
|
requirements:
|
|
107
|
-
- - "
|
|
87
|
+
- - ">="
|
|
108
88
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
89
|
+
version: '0'
|
|
110
90
|
type: :development
|
|
111
91
|
prerelease: false
|
|
112
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
93
|
requirements:
|
|
114
|
-
- - "
|
|
94
|
+
- - ">="
|
|
115
95
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '
|
|
96
|
+
version: '0'
|
|
117
97
|
- !ruby/object:Gem::Dependency
|
|
118
|
-
name:
|
|
98
|
+
name: mysql2
|
|
119
99
|
requirement: !ruby/object:Gem::Requirement
|
|
120
100
|
requirements:
|
|
121
|
-
- - "
|
|
101
|
+
- - ">="
|
|
122
102
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: '0
|
|
103
|
+
version: '0'
|
|
124
104
|
type: :development
|
|
125
105
|
prerelease: false
|
|
126
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
107
|
requirements:
|
|
128
|
-
- - "
|
|
108
|
+
- - ">="
|
|
129
109
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0
|
|
110
|
+
version: '0'
|
|
131
111
|
- !ruby/object:Gem::Dependency
|
|
132
|
-
name:
|
|
112
|
+
name: pg
|
|
133
113
|
requirement: !ruby/object:Gem::Requirement
|
|
134
114
|
requirements:
|
|
135
|
-
- - "
|
|
115
|
+
- - ">="
|
|
136
116
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '
|
|
117
|
+
version: '0'
|
|
138
118
|
type: :development
|
|
139
119
|
prerelease: false
|
|
140
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
121
|
requirements:
|
|
142
|
-
- - "
|
|
122
|
+
- - ">="
|
|
143
123
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '
|
|
124
|
+
version: '0'
|
|
145
125
|
- !ruby/object:Gem::Dependency
|
|
146
|
-
name:
|
|
126
|
+
name: pry
|
|
147
127
|
requirement: !ruby/object:Gem::Requirement
|
|
148
128
|
requirements:
|
|
149
|
-
- - "
|
|
129
|
+
- - ">="
|
|
150
130
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: 0
|
|
131
|
+
version: '0'
|
|
152
132
|
type: :development
|
|
153
133
|
prerelease: false
|
|
154
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
155
135
|
requirements:
|
|
156
|
-
- - "
|
|
136
|
+
- - ">="
|
|
157
137
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: 0
|
|
138
|
+
version: '0'
|
|
159
139
|
- !ruby/object:Gem::Dependency
|
|
160
|
-
name:
|
|
140
|
+
name: rubocop
|
|
161
141
|
requirement: !ruby/object:Gem::Requirement
|
|
162
142
|
requirements:
|
|
163
|
-
- - "~>"
|
|
164
|
-
- !ruby/object:Gem::Version
|
|
165
|
-
version: '0.18'
|
|
166
143
|
- - ">="
|
|
167
144
|
- !ruby/object:Gem::Version
|
|
168
|
-
version: 0
|
|
145
|
+
version: '0'
|
|
169
146
|
type: :development
|
|
170
147
|
prerelease: false
|
|
171
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
172
149
|
requirements:
|
|
173
|
-
- - "~>"
|
|
174
|
-
- !ruby/object:Gem::Version
|
|
175
|
-
version: '0.18'
|
|
176
150
|
- - ">="
|
|
177
151
|
- !ruby/object:Gem::Version
|
|
178
|
-
version: 0
|
|
152
|
+
version: '0'
|
|
179
153
|
description: pin some task around deployment to execute them during deployment circle
|
|
180
154
|
email:
|
|
181
155
|
- skcc321@gmail.com
|
|
@@ -190,7 +164,9 @@ files:
|
|
|
190
164
|
- app/models/deploy_pin/record.rb
|
|
191
165
|
- lib/deploy_pin.rb
|
|
192
166
|
- lib/deploy_pin/collector.rb
|
|
167
|
+
- lib/deploy_pin/database.rb
|
|
193
168
|
- lib/deploy_pin/engine.rb
|
|
169
|
+
- lib/deploy_pin/parallel_wrapper.rb
|
|
194
170
|
- lib/deploy_pin/runner.rb
|
|
195
171
|
- lib/deploy_pin/task.rb
|
|
196
172
|
- lib/deploy_pin/task_criteria.rb
|
|
@@ -209,7 +185,7 @@ licenses:
|
|
|
209
185
|
- MIT
|
|
210
186
|
metadata:
|
|
211
187
|
allowed_push_host: https://rubygems.org
|
|
212
|
-
post_install_message:
|
|
188
|
+
post_install_message:
|
|
213
189
|
rdoc_options: []
|
|
214
190
|
require_paths:
|
|
215
191
|
- lib
|
|
@@ -224,8 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
224
200
|
- !ruby/object:Gem::Version
|
|
225
201
|
version: '0'
|
|
226
202
|
requirements: []
|
|
227
|
-
rubygems_version: 3.
|
|
228
|
-
signing_key:
|
|
203
|
+
rubygems_version: 3.2.22
|
|
204
|
+
signing_key:
|
|
229
205
|
specification_version: 4
|
|
230
206
|
summary: pin some task around deployment
|
|
231
207
|
test_files: []
|