foreman-tasks 0.6.0 → 0.6.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.
@@ -11,6 +11,9 @@ module ForemanTasks
|
|
11
11
|
# the number of threads in the pool handling the execution
|
12
12
|
attr_accessor :pool_size
|
13
13
|
|
14
|
+
# the size of db connection pool
|
15
|
+
attr_accessor :db_pool_size
|
16
|
+
|
14
17
|
# set true if the executor runs externally (by default true in procution, othewise false)
|
15
18
|
attr_accessor :remote
|
16
19
|
alias_method :remote?, :remote
|
@@ -34,6 +37,7 @@ module ForemanTasks
|
|
34
37
|
self.action_logger = Rails.logger
|
35
38
|
self.dynflow_logger = Rails.logger
|
36
39
|
self.pool_size = 5
|
40
|
+
self.db_pool_size = pool_size + 5
|
37
41
|
self.remote = Rails.env.production?
|
38
42
|
self.remote_socket_path = File.join(Rails.root, "tmp", "sockets", "dynflow_socket")
|
39
43
|
self.transaction_adapter = ::Dynflow::TransactionAdapters::ActiveRecord.new
|
@@ -84,6 +88,7 @@ module ForemanTasks
|
|
84
88
|
def default_sequel_adapter_options
|
85
89
|
db_config = ActiveRecord::Base.configurations[Rails.env].dup
|
86
90
|
db_config['adapter'] = 'postgres' if db_config['adapter'] == 'postgresql'
|
91
|
+
db_config['max_connections'] = db_config['pool'] if db_config['pool']
|
87
92
|
|
88
93
|
if db_config['adapter'] == 'sqlite3'
|
89
94
|
db_config['adapter'] = 'sqlite'
|
@@ -107,7 +112,20 @@ module ForemanTasks
|
|
107
112
|
|
108
113
|
# Sequel adapter based on Rails app database.yml configuration
|
109
114
|
def initialize_persistence
|
115
|
+
unless remote?
|
116
|
+
increase_db_pool_size
|
117
|
+
end
|
110
118
|
ForemanTasks::Dynflow::Persistence.new(default_sequel_adapter_options)
|
111
119
|
end
|
120
|
+
|
121
|
+
# To avoid pottential timeouts on db connection pool, make sure
|
122
|
+
# we have the pool bigger than the thread pool
|
123
|
+
def increase_db_pool_size
|
124
|
+
ActiveRecord::Base.connection_pool.disconnect!
|
125
|
+
|
126
|
+
config = ActiveRecord::Base.configurations[Rails.env]
|
127
|
+
config['pool'] = db_pool_size if config['pool'].to_i < db_pool_size
|
128
|
+
ActiveRecord::Base.establish_connection(config)
|
129
|
+
end
|
112
130
|
end
|
113
131
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
12
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|