govuk_app_config 1.2.1 → 1.3.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
- SHA1:
3
- metadata.gz: f75a510e41a852ad4de24feb231868a11cbe2d72
4
- data.tar.gz: 3c132b844a90fd02e1ab4420f96f862f372ceb39
2
+ SHA256:
3
+ metadata.gz: cfbbf851de1ea4b966c7f5ba023721ca63de31f44de65a991c66f7753ff8cb8f
4
+ data.tar.gz: ac5b1d8780279f8307d4aba4e8350b4aecaf52939bb60fd2bb1e75e566e41aeb
5
5
  SHA512:
6
- metadata.gz: 2d0c6306d1875583b42cb1e05463b473b53266fec17b333a11bd636024b81e982afb32c105671e2d39ab2c16998db16b32c95e8af8850bc2a0fb14bd6398cec3
7
- data.tar.gz: 490dea815d8deec8623a23fed6984c3bdf98772bcc8fb36c346482e71518ffdd24d6aa6c71f48990740ba397e37cf61fa80816a7c05d7b964973c71db0da60f1
6
+ metadata.gz: 99d9c59c7815739ff8d4c95a3eaf8dd0404fd990d406569de4d8ee1a686c9b7be725e8f1a4208d72939686a9062657848857b1535f28dbbd9333264798435863
7
+ data.tar.gz: ba27e95fb497c8c30b1a6876f20c2e4ba4bb546aa5f1280270865b3cb01818aa554332df53e238ab5dadb3271948ddc0782f9e0d61a535146388292f162ad99a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # 1.3.0
2
+
3
+ * Include a class to configure unicorn to the common GOV.UK configuration
4
+
5
+ ### How to upgrade
6
+
7
+ * Find or create a config/unicorn.rb file in the app
8
+ * At the top of the file insert:
9
+ ```rb
10
+ require "govuk_app_config"
11
+ GovukUnicorn.configure(self)
12
+ ```
13
+ * If the app has the following, remove it:
14
+ ```rb
15
+ # Load the system-wide standard Unicorn file
16
+ def load_file_if_exists(config, file)
17
+ config.instance_eval(File.read(file)) if File.exist?(file)
18
+ end
19
+ load_file_if_exists(self, "/etc/govuk/unicorn.rb")
20
+ ```
21
+
1
22
  # 1.2.1
2
23
 
3
24
  * Use `INFO` log level for the default Rails logger
data/README.md CHANGED
@@ -12,18 +12,34 @@ Adds the basics of a GOV.UK application:
12
12
  Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
- gem 'govuk_app_config'
15
+ gem "govuk_app_config"
16
16
  ```
17
17
 
18
18
  And then execute:
19
19
 
20
20
  $ bundle
21
21
 
22
- ## Usage
23
22
 
24
23
  ## Unicorn
25
24
 
26
- No configuration required.
25
+ ### Configuration
26
+
27
+ Find or create a `config/unicorn.rb` in the app
28
+
29
+ At the start of the file insert:
30
+
31
+ ```rb
32
+ require "govuk_app_config"
33
+ GovukUnicorn.configure(self)
34
+ ```
35
+
36
+ ### Usage
37
+
38
+ To serve an app with unicorn run:
39
+
40
+ ```sh
41
+ $ bundle exec unicorn -c config/unicorn.rb
42
+ ```
27
43
 
28
44
  ## Error reporting
29
45
 
@@ -34,7 +50,7 @@ If you include `govuk_app_config` in your `Gemfile`, Rails' autoloading mechanis
34
50
  If you use the gem outside of Rails you'll have to explicitly require it:
35
51
 
36
52
  ```rb
37
- require 'govuk_app_config'
53
+ require "govuk_app_config"
38
54
  ```
39
55
 
40
56
  Your app will have to have the following environment variables set:
@@ -62,9 +78,9 @@ Extra parameters are:
62
78
  ```rb
63
79
  GovukError.notify(
64
80
  "Oops",
65
- extra: { offending_content_id: '123' }, # Additional context for this event. Must be a hash. Children can be any native JSON type.
66
- level: 'debug', # debug, info, warning, error, fatal
67
- tags: { key: 'value' } # Tags to index with this event. Must be a mapping of strings.
81
+ extra: { offending_content_id: "123" }, # Additional context for this event. Must be a hash. Children can be any native JSON type.
82
+ level: "debug", # debug, info, warning, error, fatal
83
+ tags: { key: "value" } # Tags to index with this event. Must be a mapping of strings.
68
84
  )
69
85
  ```
70
86
 
@@ -87,12 +103,12 @@ Use `GovukStatsd` to send stats to graphite. It has the same interface as [the R
87
103
  Examples:
88
104
 
89
105
  ```ruby
90
- GovukStatsd.increment 'garets'
91
- GovukStatsd.timing 'glork', 320
92
- GovukStatsd.gauge 'bork', 100
106
+ GovukStatsd.increment "garets"
107
+ GovukStatsd.timing "glork", 320
108
+ GovukStatsd.gauge "bork", 100
93
109
 
94
110
  # Use {#time} to time the execution of a block
95
- GovukStatsd.time('account.activate') { @account.activate! }
111
+ GovukStatsd.time("account.activate") { @account.activate! }
96
112
  ```
97
113
 
98
114
  ## Rails logging
@@ -0,0 +1,17 @@
1
+ module GovukUnicorn
2
+ def self.configure(config)
3
+ config.worker_processes Integer(ENV.fetch("UNICORN_WORKER_PROCESSES", 2))
4
+
5
+ if ENV["GOVUK_APP_LOGROOT"]
6
+ config.stdout_path "#{ENV['GOVUK_APP_LOGROOT']}/app.out.log"
7
+ config.stderr_path "#{ENV['GOVUK_APP_LOGROOT']}/app.err.log"
8
+ end
9
+
10
+ config.before_exec do |server|
11
+ next unless ENV["GOVUK_APP_ROOT"]
12
+ ENV["BUNDLE_GEMFILE"] = "#{ENV['GOVUK_APP_ROOT']}/Gemfile"
13
+ end
14
+
15
+ config.check_client_connection true
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module GovukAppConfig
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -2,5 +2,6 @@ require "govuk_app_config/version"
2
2
  require "govuk_app_config/govuk_statsd"
3
3
  require "govuk_app_config/govuk_error"
4
4
  require "govuk_app_config/govuk_logging"
5
+ require "govuk_app_config/govuk_unicorn"
5
6
  require "govuk_app_config/configure"
6
7
  require "govuk_app_config/railtie" if defined?(Rails)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_app_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: statsd-ruby
@@ -160,6 +160,7 @@ files:
160
160
  - lib/govuk_app_config/govuk_error.rb
161
161
  - lib/govuk_app_config/govuk_logging.rb
162
162
  - lib/govuk_app_config/govuk_statsd.rb
163
+ - lib/govuk_app_config/govuk_unicorn.rb
163
164
  - lib/govuk_app_config/railtie.rb
164
165
  - lib/govuk_app_config/version.rb
165
166
  homepage: https://github.com/alphagov/govuk_app_config
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  version: '0'
183
184
  requirements: []
184
185
  rubyforge_project:
185
- rubygems_version: 2.6.13
186
+ rubygems_version: 2.7.3
186
187
  signing_key:
187
188
  specification_version: 4
188
189
  summary: Base configuration for GOV.UK applications