web47core 3.4.11.1 → 3.4.13.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 +4 -4
- data/README.md +13 -9
- data/lib/app/models/concerns/aws_configuration.rb +3 -0
- data/lib/app/services/auto_scaler.rb +14 -0
- data/lib/web47core/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80baf5d5e7bfb1fb06d5ac899fdd3e59b2e4bdcb386ef9fdc37dffc8d30b0012
|
|
4
|
+
data.tar.gz: 41b4aa9bf63b57afd0c1c3551b91ba6a981264612ef8d1912131366b29d75909
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6bd86b9c557fad1baf4f216489c8aba2b29b0cce09dca8062875f6693d68dc55523e776b62cc482369add0208ea386c03eb177b2c87406af0f286dda1159480e
|
|
7
|
+
data.tar.gz: b1f3e69f89b5e4897f377733189a26b50b985fe8b039b47881015f0860ef15df0739e5628ef9cd0ddf46c0ef379100cd50d2b379e26cef59f3783a69b76836cc
|
data/README.md
CHANGED
|
@@ -10,21 +10,20 @@ Core components used commonly among all web apps for both App47 and RedMonocle
|
|
|
10
10
|
|
|
11
11
|
## Requirements
|
|
12
12
|
|
|
13
|
-
*
|
|
14
|
-
* Ruby 3.4.11 or newer. This repository develops on 3.4.11.
|
|
13
|
+
* Ruby 3.4.13 or newer. This repository develops on 3.4.13.
|
|
15
14
|
|
|
16
15
|
### Working with Bundler and RBENV
|
|
17
16
|
|
|
18
17
|
This project manages [RBENV](https://github.com/rbenv/rbenv) and manages dependencies via [Bundler](http://gembundler.com/).
|
|
19
18
|
|
|
20
19
|
You must first [install RBENV](https://github.com/rbenv/rbenv#installation).
|
|
21
|
-
Then install Ruby 3.4.
|
|
20
|
+
Then install Ruby 3.4.13 via RBENV
|
|
22
21
|
``` shell script
|
|
23
|
-
rbenv install 3.4.
|
|
22
|
+
rbenv install 3.4.13
|
|
24
23
|
```
|
|
25
|
-
You'll now notice that this project (as well as other App47 ones) contains a .ruby-version file, which is executed upon opening the project's root directory in a terminal (and IDE's like RubyMine). The .ruby-version file simply states `3.4.
|
|
24
|
+
You'll now notice that this project (as well as other App47 ones) contains a .ruby-version file, which is executed upon opening the project's root directory in a terminal (and IDE's like RubyMine). The .ruby-version file simply states `3.4.13` which tells RBENV to ensure the Ruby version to use for this project is 3.4.13.
|
|
26
25
|
|
|
27
|
-
Please note, your Ruby `3.4.
|
|
26
|
+
Please note, your Ruby `3.4.13` version might need bundler installed:
|
|
28
27
|
``` shell script
|
|
29
28
|
gem install bundler -v 4.0.3
|
|
30
29
|
```
|
|
@@ -48,6 +47,10 @@ The `web47core` project is a gem that will be deployed via [Ruby Gems](https://r
|
|
|
48
47
|
2. Post the gem to the DevOps channel in slack, ask for it to be added to the S3 repo.
|
|
49
48
|
|
|
50
49
|
## Usage
|
|
50
|
+
### Worker autoscaling
|
|
51
|
+
|
|
52
|
+
`AutoScaler.check` follows `Web47core::Config.worker_ladder` and keeps existing workers until the non-failed job queue is empty. If jobs are queued but both the ladder and ECS desired count are zero, it requests one worker after more than `SystemConfiguration.aws_worker_max_wait_minutes` without a worker check-in (default: 45 minutes). Set the wait with `SystemConfiguration.configuration.update!(aws_worker_max_wait_minutes: 30)`; it must be a positive integer. With no check-in history, it requests one immediately. The cron primary checks once a minute; ECS startup takes additional time.
|
|
53
|
+
|
|
51
54
|
### Importing the gem
|
|
52
55
|
To use the `web47core` gem in a project, first add the gem to your Gemfile in one of two ways
|
|
53
56
|
|
|
@@ -256,13 +259,14 @@ bundle exec delayed_job stop
|
|
|
256
259
|
```
|
|
257
260
|
|
|
258
261
|
##### Delayed Job Management
|
|
259
|
-
|
|
260
|
-
exceed the max allowed time for a job to run. To configure this, update the delayed job initializer to add the `TimeKeeper` plugin.
|
|
262
|
+
Register `TimeKeeper` once in the host application’s delayed-job initializer. It records worker check-ins and job runs, which the autoscaler uses to detect idle workers.
|
|
261
263
|
|
|
262
264
|
```ruby
|
|
263
|
-
Delayed::Worker.plugins
|
|
265
|
+
Delayed::Worker.plugins |= [Delayed::Plugins::TimeKeeper]
|
|
264
266
|
```
|
|
265
267
|
|
|
268
|
+
Automatic orphaned-job restarts remain controlled by `delayed_job_restart_orphaned`, which defaults to false.
|
|
269
|
+
|
|
266
270
|
This will add a few now cron jobs as well as objects to the project, you can view these by adding the following routes near the delayed jobs area
|
|
267
271
|
|
|
268
272
|
```ruby
|
|
@@ -17,9 +17,12 @@ module AwsConfiguration
|
|
|
17
17
|
field :aws_desired_worker_count, type: Integer, default: 0
|
|
18
18
|
# ECS service desired count from the last DescribeServices. Not the running task count.
|
|
19
19
|
field :aws_current_worker_count, type: Integer, default: 0
|
|
20
|
+
# Maximum time without a worker check-in before overriding a zero-worker rung.
|
|
21
|
+
field :aws_worker_max_wait_minutes, type: Integer, default: 45
|
|
20
22
|
|
|
21
23
|
validates :aws_desired_worker_count, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
|
22
24
|
validates :aws_current_worker_count, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
|
25
|
+
validates :aws_worker_max_wait_minutes, numericality: { only_integer: true, greater_than: 0 }
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
|
|
@@ -9,6 +9,10 @@ require 'singleton'
|
|
|
9
9
|
# the worker ladder. It does not shrink the fleet while any job is still
|
|
10
10
|
# queued, including when the ladder maps that depth to zero workers. It
|
|
11
11
|
# scales to zero only when the queue is empty.
|
|
12
|
+
# If the ladder and live desired count are zero with jobs queued, check
|
|
13
|
+
# starts one worker after the configured wait without a worker check-in
|
|
14
|
+
# (or immediately when there is no worker history). SystemConfiguration's
|
|
15
|
+
# aws_worker_max_wait_minutes defaults to 45.
|
|
12
16
|
# warm_up raises the fleet to at least the requested floor. bump_worker adds
|
|
13
17
|
# one worker. Neither call consults the ladder or the queue, and neither
|
|
14
18
|
# lowers a fleet that is already larger.
|
|
@@ -102,6 +106,8 @@ class AutoScaler
|
|
|
102
106
|
return
|
|
103
107
|
end
|
|
104
108
|
|
|
109
|
+
target = 1 if job_count.positive? && target.zero? && current.zero? && worker_check_in_overdue?
|
|
110
|
+
|
|
105
111
|
# Keep the live fleet while any job remains. The ladder still chooses a
|
|
106
112
|
# larger fleet. Scale down only once the queue is empty.
|
|
107
113
|
if job_count.positive? && target < current
|
|
@@ -123,6 +129,14 @@ class AutoScaler
|
|
|
123
129
|
update_service(target)
|
|
124
130
|
end
|
|
125
131
|
|
|
132
|
+
def worker_check_in_overdue?
|
|
133
|
+
cutoff = configuration.aws_worker_max_wait_minutes.minutes.ago
|
|
134
|
+
!Delayed::Jobs::Worker.where(:last_check_in_at.gte => cutoff).exists?
|
|
135
|
+
rescue StandardError => error
|
|
136
|
+
App47Logger.log_error 'Unable to determine worker max wait minutes for worker', error
|
|
137
|
+
false
|
|
138
|
+
end
|
|
139
|
+
|
|
126
140
|
def desired_for(job_count)
|
|
127
141
|
worker_ladder.each do |range, workers|
|
|
128
142
|
return workers if range.cover?(job_count)
|
data/lib/web47core/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: web47core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.4.
|
|
4
|
+
version: 3.4.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Schroeder
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
version: '7.2'
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: '8.
|
|
21
|
+
version: '8.0'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -28,7 +28,7 @@ dependencies:
|
|
|
28
28
|
version: '7.2'
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: '8.
|
|
31
|
+
version: '8.0'
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
33
|
name: activesupport
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -38,7 +38,7 @@ dependencies:
|
|
|
38
38
|
version: '7.2'
|
|
39
39
|
- - "<"
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '8.
|
|
41
|
+
version: '8.0'
|
|
42
42
|
type: :runtime
|
|
43
43
|
prerelease: false
|
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -48,7 +48,7 @@ dependencies:
|
|
|
48
48
|
version: '7.2'
|
|
49
49
|
- - "<"
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
|
-
version: '8.
|
|
51
|
+
version: '8.0'
|
|
52
52
|
- !ruby/object:Gem::Dependency
|
|
53
53
|
name: cancancan
|
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -420,7 +420,7 @@ dependencies:
|
|
|
420
420
|
version: '7.2'
|
|
421
421
|
- - "<"
|
|
422
422
|
- !ruby/object:Gem::Version
|
|
423
|
-
version: '8.
|
|
423
|
+
version: '8.0'
|
|
424
424
|
type: :development
|
|
425
425
|
prerelease: false
|
|
426
426
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -430,7 +430,7 @@ dependencies:
|
|
|
430
430
|
version: '7.2'
|
|
431
431
|
- - "<"
|
|
432
432
|
- !ruby/object:Gem::Version
|
|
433
|
-
version: '8.
|
|
433
|
+
version: '8.0'
|
|
434
434
|
- !ruby/object:Gem::Dependency
|
|
435
435
|
name: railties
|
|
436
436
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -440,7 +440,7 @@ dependencies:
|
|
|
440
440
|
version: '7.2'
|
|
441
441
|
- - "<"
|
|
442
442
|
- !ruby/object:Gem::Version
|
|
443
|
-
version: '8.
|
|
443
|
+
version: '8.0'
|
|
444
444
|
type: :development
|
|
445
445
|
prerelease: false
|
|
446
446
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -450,7 +450,7 @@ dependencies:
|
|
|
450
450
|
version: '7.2'
|
|
451
451
|
- - "<"
|
|
452
452
|
- !ruby/object:Gem::Version
|
|
453
|
-
version: '8.
|
|
453
|
+
version: '8.0'
|
|
454
454
|
- !ruby/object:Gem::Dependency
|
|
455
455
|
name: rubocop
|
|
456
456
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -6695,7 +6695,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
6695
6695
|
requirements:
|
|
6696
6696
|
- - ">="
|
|
6697
6697
|
- !ruby/object:Gem::Version
|
|
6698
|
-
version: 3.4.
|
|
6698
|
+
version: 3.4.13
|
|
6699
6699
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
6700
6700
|
requirements:
|
|
6701
6701
|
- - ">="
|