config_skeleton 0.1.0 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +48 -0
- data/.rspec +1 -0
- data/README.md +1 -1
- data/config_skeleton.gemspec +4 -9
- data/lib/config_skeleton.rb +37 -1
- metadata +42 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d55ae63c3cac3ec4c77ae3d20c2a8078fa65e937abdeaf10afae589f7e45d85
|
4
|
+
data.tar.gz: 07c2dc5afd603e1e8c61ff0f5b6d7b5cbb0ce9ce510c8c645279c683f5adee4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ed1a58c33de8eca24db5823d221bde84e64a9bcba91d2007ac68095da458c61fd50ef24670b96c2186a577ab91c2fa90c289c680e4310abbdbf9a34f6339754
|
7
|
+
data.tar.gz: 8932f5e8ee5545644a7d5d7950f5737b256ad9c4eb10cb1c0dd8f0b8333fd22d62557c0afa011b83ec508eb94b1f94068b7558ee082ce9f45f75448309b64e77
|
@@ -0,0 +1,48 @@
|
|
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: CvX/publish-rubygems-action@master
|
47
|
+
env:
|
48
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/README.md
CHANGED
@@ -41,7 +41,7 @@ conduct](CODE_OF_CONDUCT.md).
|
|
41
41
|
Unless otherwise stated, everything in this repo is covered by the following
|
42
42
|
copyright notice:
|
43
43
|
|
44
|
-
Copyright (C)
|
44
|
+
Copyright (C) 2020 Civilized Discourse Construction Kit, Inc.
|
45
45
|
|
46
46
|
This program is free software: you can redistribute it and/or modify it
|
47
47
|
under the terms of the GNU General Public License version 3, as
|
data/config_skeleton.gemspec
CHANGED
@@ -1,14 +1,7 @@
|
|
1
|
-
begin
|
2
|
-
require 'git-version-bump'
|
3
|
-
rescue LoadError
|
4
|
-
nil
|
5
|
-
end
|
6
|
-
|
7
1
|
Gem::Specification.new do |s|
|
8
2
|
s.name = "config_skeleton"
|
9
3
|
|
10
|
-
s.version =
|
11
|
-
s.date = GVB.date rescue Time.now.strftime("%Y-%m-%d")
|
4
|
+
s.version = "0.2.6"
|
12
5
|
|
13
6
|
s.platform = Gem::Platform::RUBY
|
14
7
|
|
@@ -29,9 +22,11 @@ Gem::Specification.new do |s|
|
|
29
22
|
|
30
23
|
s.add_development_dependency 'bundler'
|
31
24
|
s.add_development_dependency 'github-release'
|
32
|
-
s.add_development_dependency 'git-version-bump'
|
33
25
|
s.add_development_dependency 'rake', "~> 12.0"
|
34
26
|
s.add_development_dependency 'redcarpet'
|
35
27
|
s.add_development_dependency 'rubocop'
|
36
28
|
s.add_development_dependency 'yard'
|
29
|
+
s.add_development_dependency 'rspec'
|
30
|
+
s.add_development_dependency 'pry'
|
31
|
+
s.add_development_dependency 'pry-byebug'
|
37
32
|
end
|
data/lib/config_skeleton.rb
CHANGED
@@ -142,6 +142,18 @@ class ConfigSkeleton < ServiceSkeleton
|
|
142
142
|
# If you get this, someone didn't read the documentation.
|
143
143
|
class NotImplementedError < Error; end
|
144
144
|
|
145
|
+
# It is useful for consumers to manually request a config regen. An instance
|
146
|
+
# of this class is made via the regen_notifier method.
|
147
|
+
class ConfigRegenNotifier
|
148
|
+
def initialize(io_write)
|
149
|
+
@io_write = io_write
|
150
|
+
end
|
151
|
+
|
152
|
+
def trigger_regen
|
153
|
+
@io_write << "."
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
145
157
|
# Declare a file watch on all instances of the config generator.
|
146
158
|
#
|
147
159
|
# When you're looking to watch a file whose path is well-known and never-changing, you
|
@@ -188,6 +200,18 @@ class ConfigSkeleton < ServiceSkeleton
|
|
188
200
|
end
|
189
201
|
|
190
202
|
initialize_config_skeleton_metrics
|
203
|
+
@trigger_regen_r, @trigger_regen_w = IO.pipe
|
204
|
+
end
|
205
|
+
|
206
|
+
# Expose the write pipe which can be written to to trigger a config
|
207
|
+
# regeneration with a forced reload; a similar mechanism is used for
|
208
|
+
# shutdown but in that case writes are managed internally.
|
209
|
+
#
|
210
|
+
# Usage: config.regen_notifier.trigger_regen
|
211
|
+
#
|
212
|
+
# @return [ConfigRegenNotifier]
|
213
|
+
def regen_notifier
|
214
|
+
@regen_notifier ||= ConfigRegenNotifier.new(@trigger_regen_w)
|
191
215
|
end
|
192
216
|
|
193
217
|
# Set the config generator running.
|
@@ -209,7 +233,11 @@ class ConfigSkeleton < ServiceSkeleton
|
|
209
233
|
@terminate_r, @terminate_w = IO.pipe
|
210
234
|
|
211
235
|
loop do
|
212
|
-
if ios = IO.select(
|
236
|
+
if ios = IO.select(
|
237
|
+
[notifier.to_io, @terminate_r, @trigger_regen_r],
|
238
|
+
[], [],
|
239
|
+
sleep_duration.tap { |d| logger.debug(logloc) { "Sleeping for #{d} seconds" } }
|
240
|
+
)
|
213
241
|
if ios.first.include?(notifier.to_io)
|
214
242
|
logger.debug(logloc) { "inotify triggered" }
|
215
243
|
notifier.process
|
@@ -217,6 +245,14 @@ class ConfigSkeleton < ServiceSkeleton
|
|
217
245
|
elsif ios.first.include?(@terminate_r)
|
218
246
|
logger.debug(logloc) { "triggered by termination pipe" }
|
219
247
|
break
|
248
|
+
elsif ios.first.include?(@trigger_regen_r)
|
249
|
+
# we want to wait until everything in the backlog is read
|
250
|
+
# before proceeding so we don't run out of buffer memory
|
251
|
+
# for the pipe
|
252
|
+
while @trigger_regen_r.read_nonblock(20, nil, exception: false) != :wait_readable; end
|
253
|
+
|
254
|
+
logger.debug(logloc) { "triggered by regen pipe" }
|
255
|
+
regenerate_config(force_reload: true)
|
220
256
|
else
|
221
257
|
logger.error(logloc) { "Mysterious return from select: #{ios.inspect}" }
|
222
258
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_skeleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Palmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|
@@ -95,7 +95,21 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '12.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '12.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: redcarpet
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - ">="
|
@@ -109,21 +123,21 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: rubocop
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - "
|
136
|
+
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: yard
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - ">="
|
@@ -137,7 +151,7 @@ dependencies:
|
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
154
|
+
name: rspec
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
@@ -151,7 +165,21 @@ dependencies:
|
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
168
|
+
name: pry
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: pry-byebug
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
156
184
|
requirements:
|
157
185
|
- - ">="
|
@@ -171,7 +199,9 @@ executables: []
|
|
171
199
|
extensions: []
|
172
200
|
extra_rdoc_files: []
|
173
201
|
files:
|
202
|
+
- ".github/workflows/ruby.yml"
|
174
203
|
- ".gitignore"
|
204
|
+
- ".rspec"
|
175
205
|
- ".rubocop.yml"
|
176
206
|
- ".yardopts"
|
177
207
|
- CODE_OF_CONDUCT.md
|
@@ -198,8 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
228
|
- !ruby/object:Gem::Version
|
199
229
|
version: '0'
|
200
230
|
requirements: []
|
201
|
-
|
202
|
-
rubygems_version: 2.7.7
|
231
|
+
rubygems_version: 3.0.3
|
203
232
|
signing_key:
|
204
233
|
specification_version: 4
|
205
234
|
summary: Dynamically generate configs and reload servers
|