config_skeleton 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99dfaca5fbeaf8f2bd6c5fd921e854294cd1f01be8e27613ad58e7581e7b1bf5
4
- data.tar.gz: 552d8592225a20807716bd74ab8eaf1866b25a1d8b7acec75eedb98d22cb95cf
3
+ metadata.gz: dadb672b628b814c3962711ce001733dacda07fa75c1b9b418f389719af745b1
4
+ data.tar.gz: 32f6f9d54602208c9a8c7402b1e6a12d8f9e2045307b929537d69f09c56adda7
5
5
  SHA512:
6
- metadata.gz: 4748a0d790e28a991555bf8647d79c71f827ba41d7d9a48156d9783a1e8e7ddefbe1acb4417c92667cb128e9c542b1e2aaa000d4adafa68aaf0a058d1e620d2d
7
- data.tar.gz: 8cd5d2474c55a59255d53c1ed87bfb5c1a5bebe8df32117f9c49c4486ba1647a263c397606a0afb5fd67e22edaffd2df6c436ee8fb866b4bb066ff3d395960f9
6
+ metadata.gz: 0cc9b1b46bbdeaa6c07850cad5dbe60b05d7bfadaf8cfa9d963a794e1320051463c74c94cef78822b7bd115567fed8622b1370068fdba079e3926cebd70b3dba
7
+ data.tar.gz: 64fc6ba379d78027b99f575eaa256b305e5dac656e9504d35b697d07c0d3fb5ac89793668d62046f1e500f8c59e3f4cdf47052a4ac62717f856206dd06a9f183
@@ -0,0 +1,50 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+ - main
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - 2.5
18
+ - 2.6
19
+ - 2.7
20
+ - 3.0
21
+
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+
25
+ - name: Setup ruby
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+
31
+ - name: Lint
32
+ run: bundle exec rubocop
33
+
34
+ - name: Tests
35
+ run: bundle exec rake test
36
+
37
+ publish:
38
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
39
+ needs: build
40
+ runs-on: ubuntu-latest
41
+
42
+ steps:
43
+ - uses: actions/checkout@v2
44
+
45
+ - name: Release Gem
46
+ uses: discourse/publish-rubygems-action@v2-beta
47
+ env:
48
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
49
+ GIT_EMAIL: team@discourse.org
50
+ GIT_NAME: discoursebot
data/.gitignore CHANGED
@@ -1,9 +1,2 @@
1
1
  /Gemfile.lock
2
- /pkg
3
- /doc
4
- /.yardoc
5
- /coverage
6
- /.bundle
7
2
  /cfg.txt
8
-
9
- .rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
data/.rubocop.yml CHANGED
@@ -1 +1,2 @@
1
- inherit_from: https://raw.githubusercontent.com/discourse/discourse/master/.rubocop.yml
1
+ inherit_gem:
2
+ rubocop-discourse: default.yml
@@ -2,31 +2,27 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "config_skeleton"
5
-
6
- s.version = "2.0.0"
5
+ s.version = "2.1.0"
7
6
 
8
7
  s.platform = Gem::Platform::RUBY
9
-
10
8
  s.summary = "Dynamically generate configs and reload servers"
11
-
12
9
  s.authors = ["Matt Palmer", "Discourse Team"]
13
10
  s.email = ["matt.palmer@discourse.org", "team@discourse.org"]
14
11
  s.homepage = "https://github.com/discourse/config_skeleton"
15
12
 
16
13
  s.files = `git ls-files -z`.split("\0").reject { |f| f =~ /^(G|spec|Rakefile)/ }
17
14
 
18
- s.required_ruby_version = ">= 2.3.0"
15
+ s.required_ruby_version = ">= 2.5.0"
19
16
 
20
17
  s.add_runtime_dependency 'diffy', '~> 3.0'
21
18
  s.add_runtime_dependency 'rb-inotify', '~> 0.9'
22
19
  s.add_runtime_dependency 'service_skeleton', "~> 2.0"
20
+ s.add_runtime_dependency 'webrick'
23
21
 
24
22
  s.add_development_dependency 'bundler'
25
- s.add_development_dependency 'github-release'
26
- s.add_development_dependency 'rake', "~> 12.0"
23
+ s.add_development_dependency 'rake', "~> 13.0"
27
24
  s.add_development_dependency 'redcarpet'
28
- s.add_development_dependency 'rubocop'
29
- s.add_development_dependency 'rubocop-discourse'
25
+ s.add_development_dependency 'rubocop-discourse', '~> 2.4.1'
30
26
  s.add_development_dependency 'yard'
31
27
  s.add_development_dependency 'rspec'
32
28
  s.add_development_dependency 'pry'
@@ -207,11 +207,15 @@ class ConfigSkeleton
207
207
  @watches || []
208
208
  end
209
209
 
210
- def initialize(*_)
210
+ def initialize(*_, metrics:, config:)
211
211
  super
212
212
  initialize_config_skeleton_metrics
213
213
  @trigger_regen_r, @trigger_regen_w = IO.pipe
214
214
  @terminate_r, @terminate_w = IO.pipe
215
+
216
+ raise "cooldown_duration invalid" if cooldown_duration < 0
217
+ raise "sleep_duration invalid" if sleep_duration < 0
218
+ raise "sleep_duration must not be less than cooldown_duration" if sleep_duration < cooldown_duration
215
219
  end
216
220
 
217
221
  # Expose the write pipe which can be written to to trigger a config
@@ -242,11 +246,16 @@ class ConfigSkeleton
242
246
  logger.debug(logloc) { "notifier fd is #{notifier.to_io.inspect}" }
243
247
 
244
248
  loop do
245
- if ios = IO.select(
246
- [notifier.to_io, @terminate_r, @trigger_regen_r],
247
- [], [],
248
- sleep_duration.tap { |d| logger.debug(logloc) { "Sleeping for #{d} seconds" } }
249
- )
249
+ if cooldown_duration > 0
250
+ logger.debug(logloc) { "Sleeping for #{cooldown_duration} seconds (cooldown)" }
251
+ IO.select([@terminate_r], [], [], cooldown_duration)
252
+ end
253
+
254
+ timeout = sleep_duration - cooldown_duration
255
+ logger.debug(logloc) { "Sleeping for #{timeout} seconds unless interrupted" }
256
+ ios = IO.select([notifier.to_io, @terminate_r, @trigger_regen_r], [], [], timeout)
257
+
258
+ if ios
250
259
  if ios.first.include?(notifier.to_io)
251
260
  logger.debug(logloc) { "inotify triggered" }
252
261
  notifier.process
@@ -446,6 +455,25 @@ class ConfigSkeleton
446
455
  60
447
456
  end
448
457
 
458
+ # How long to ignore signals/notifications after a config regeneration
459
+ #
460
+ # Hammering a downstream service with reload requests is often a bad idea.
461
+ # This method exists to allow subclasses to define a 'cooldown' duration.
462
+ # After each config regeneration, the config generator will sleep for this
463
+ # duration, regardless of any CONT signals or inotify events. Those events
464
+ # will be queued up, and processed at the end of the cooldown.
465
+ #
466
+ # The cooldown_duration is counted as part of the sleep_duration. So for
467
+ # the default values of 60 and 5, the service will cooldown for 5s, then wait
468
+ # for 55s.
469
+ #
470
+ # @return [Integer] the number of seconds to 'cooldown' for. This *must* be
471
+ # greater than zero, and less than sleep_duration
472
+ #
473
+ def cooldown_duration
474
+ 5
475
+ end
476
+
449
477
  # The instance of INotify::Notifier that is holding our file watches.
450
478
  #
451
479
  # @return [INotify::Notifier]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_skeleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-01 00:00:00.000000000 Z
12
+ date: 2021-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: diffy
@@ -54,13 +54,13 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '2.0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: bundler
57
+ name: webrick
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
- type: :development
63
+ type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
@@ -68,7 +68,7 @@ dependencies:
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: github-release
71
+ name: bundler
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '12.0'
90
+ version: '13.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '12.0'
97
+ version: '13.0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: redcarpet
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -109,34 +109,20 @@ dependencies:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: rubocop
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
112
  - !ruby/object:Gem::Dependency
127
113
  name: rubocop-discourse
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
- - - ">="
116
+ - - "~>"
131
117
  - !ruby/object:Gem::Version
132
- version: '0'
118
+ version: 2.4.1
133
119
  type: :development
134
120
  prerelease: false
135
121
  version_requirements: !ruby/object:Gem::Requirement
136
122
  requirements:
137
- - - ">="
123
+ - - "~>"
138
124
  - !ruby/object:Gem::Version
139
- version: '0'
125
+ version: 2.4.1
140
126
  - !ruby/object:Gem::Dependency
141
127
  name: yard
142
128
  requirement: !ruby/object:Gem::Requirement
@@ -201,7 +187,7 @@ executables: []
201
187
  extensions: []
202
188
  extra_rdoc_files: []
203
189
  files:
204
- - ".github/workflows/ruby.yml"
190
+ - ".github/workflows/ci.yml"
205
191
  - ".gitignore"
206
192
  - ".rspec"
207
193
  - ".rubocop.yml"
@@ -223,14 +209,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
209
  requirements:
224
210
  - - ">="
225
211
  - !ruby/object:Gem::Version
226
- version: 2.3.0
212
+ version: 2.5.0
227
213
  required_rubygems_version: !ruby/object:Gem::Requirement
228
214
  requirements:
229
215
  - - ">="
230
216
  - !ruby/object:Gem::Version
231
217
  version: '0'
232
218
  requirements: []
233
- rubygems_version: 3.0.3
219
+ rubygems_version: 3.1.4
234
220
  signing_key:
235
221
  specification_version: 4
236
222
  summary: Dynamically generate configs and reload servers
@@ -1,48 +0,0 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
- name: Ruby
9
-
10
- on:
11
- push:
12
- branches:
13
- - master
14
- tags:
15
- - v*
16
- pull_request:
17
- branches:
18
- - master
19
- workflow_dispatch:
20
-
21
- jobs:
22
- build:
23
- runs-on: ubuntu-latest
24
-
25
- steps:
26
- - uses: actions/checkout@v2
27
-
28
- - name: Set up Ruby
29
- uses: ruby/setup-ruby@v1
30
- with:
31
- ruby-version: 2.6
32
- - name: Install dependencies
33
- run: bundle install
34
- - name: Run specs
35
- run: bundle exec rspec
36
-
37
- publish:
38
- if: contains(github.ref, 'refs/tags/v')
39
- needs: build
40
- runs-on: ubuntu-latest
41
-
42
- steps:
43
- - uses: actions/checkout@v2
44
-
45
- - name: Release Gem
46
- uses: discourse/publish-rubygems-action@main
47
- env:
48
- RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}