govuk_sidekiq 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -21
- data/lib/govuk_sidekiq/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5249ed2d422603f767f82630fe2aef1fc562694
|
4
|
+
data.tar.gz: 939f2183ce458bdc2c88c9fbddb1ce9726375570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4233329cba8c4b6e0b1c2bc33c802bef71a9500faadf790f0c8ab7edf8e8e2e95e40821e88712334dc88323fa3695dca0053e6f6ae9326620fbee00f07d3b59b
|
7
|
+
data.tar.gz: 72324357bef8207b29aa424bca58e04cc33e8773ed0b521e3267c27f1d1ce4de0ea2db1de4689327a2daabbc690a1aeadc3dcf4bfbeb1322b88c7228dbdbd835
|
data/README.md
CHANGED
@@ -1,41 +1,108 @@
|
|
1
|
-
#
|
1
|
+
# GOV.UK Sidekiq
|
2
2
|
|
3
3
|
Provides a unified set of configurations and behaviours when using Sidekiq
|
4
4
|
in GOV.UK applications.
|
5
5
|
|
6
|
-
##
|
6
|
+
## Features
|
7
7
|
|
8
|
-
|
8
|
+
What does `govuk_sidekiq` do for you?
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
1. Makes sure Sidekiq can connect to Redis correctly, using the default
|
11
|
+
environment variables (these are set in [govuk-puppet](https://github.com/alphagov/govuk-puppet)).
|
12
|
+
2. Makes sure that the correct HTTP headers are passed on to [gds-api-adapters](https://github.com/alphagov/gds-api-adapters).
|
13
|
+
This means that for each request a unique ID (govuk_request_id) will be passed on to downstream applications.
|
14
|
+
[Read more about request tracing](https://github.gds/pages/gds/opsmanual/infrastructure/howto/setting-up-request-tracing.html).
|
15
|
+
3. Makes sure that we use JSON logging, so that Sidekiq logs will end up
|
16
|
+
properly in Kibana.
|
17
|
+
4. Sends activity stats to Statsd, so that you can make pretty graphs of activity
|
18
|
+
in Grafana or Graphite. See the [Rummager dashboards for an example](https://grafana.publishing.service.gov.uk/dashboard/file/rummager_queues.json).
|
19
|
+
5. Configures Sidekiq so that exceptions will be sent to our [Errbit instance](errbit.publishing.service.gov.uk).
|
12
20
|
|
21
|
+
## Installation (Rails only)
|
13
22
|
|
14
|
-
|
15
|
-
your job is called with the wrong number invalid arguments. To set up testing
|
16
|
-
correctly, replace `require 'sidekiq/testing'` with:
|
23
|
+
### 1. Add the gem
|
17
24
|
|
18
25
|
```ruby
|
19
|
-
|
26
|
+
# Gemfile
|
27
|
+
gem "govuk_sidekiq", "~> VERSION"
|
20
28
|
```
|
21
29
|
|
22
|
-
|
30
|
+
### 2. Add a Sidekiq config file
|
31
|
+
|
32
|
+
```yaml
|
33
|
+
# config/sidekiq.yml
|
34
|
+
---
|
35
|
+
:concurrency: 2
|
36
|
+
```
|
37
|
+
|
38
|
+
This file also allows you to configure queues with priority.
|
39
|
+
[See the Sidekiq wiki for available options](https://github.com/mperham/sidekiq/wiki/Advanced-Options).
|
40
|
+
|
41
|
+
### 3. Add a Procfile
|
42
|
+
|
43
|
+
This is what puppet uses to create the process.
|
23
44
|
|
24
|
-
|
25
|
-
|
45
|
+
```sh
|
46
|
+
# Procfile
|
47
|
+
worker: bundle exec sidekiq -C ./config/sidekiq.yml
|
48
|
+
```
|
49
|
+
|
50
|
+
### 4. Configure puppet
|
51
|
+
|
52
|
+
- Set `REDIS_HOST` and `REDIS_PORT` variables. `GOVUK_APP_NAME` should also be
|
53
|
+
set, but this is already done by the default `govuk::app::config`.
|
54
|
+
- Make sure puppet creates and starts the Procfile worker.
|
55
|
+
|
56
|
+
There's no step-by-step guide for this, but [you can copy the config from collections-publisher](https://github.com/alphagov/govuk-puppet/blob/master/modules/govuk/manifests/apps/collections_publisher.pp).
|
57
|
+
|
58
|
+
### 5. Configure deployment scripts
|
59
|
+
|
60
|
+
Make sure you restart the worker after deploying by adding a hook to the [capistrano scripts in govuk-app-deployment](https://github.com/alphagov/govuk-app-deployment). Otherwise the worker will keep running old code.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# your-application/config/deploy.rb
|
64
|
+
after "deploy:restart", "deploy:restart_procfile_worker"
|
65
|
+
```
|
26
66
|
|
27
|
-
|
28
|
-
including Airbrake/Errbit, statsd, JSON logging,
|
29
|
-
and passthrough of the `govuk_request_id`.
|
67
|
+
### 6. Add your worker to the Procfile & Pinfile
|
30
68
|
|
31
|
-
|
32
|
-
environment variables:
|
69
|
+
This makes sure that your development environment behaves like production.
|
33
70
|
|
34
|
-
|
35
|
-
|
36
|
-
- **REDIS_PORT**
|
71
|
+
See the [Pinfile](https://github.gds/gds/development/blob/master/Pinfile) and
|
72
|
+
[Procfile](https://github.gds/gds/development/blob/master/Procfile) for examples.
|
37
73
|
|
38
|
-
|
74
|
+
### 7. Add app to sidekiq-monitoring
|
75
|
+
|
76
|
+
See the opsmanual for a step-by-step guide: [HOWTO: Add sidekiq-monitoring to your application](https://github.gds/pages/gds/opsmanual/infrastructure/howto/setting-up-new-sidekiq-monitoring-app.html)
|
77
|
+
|
78
|
+
### 8. Create some jobs
|
79
|
+
|
80
|
+
You can [use normal Sidekiq jobs](https://github.com/mperham/sidekiq/wiki/Getting-Started):
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
# app/workers/hard_worker.rb
|
84
|
+
class HardWorker
|
85
|
+
include Sidekiq::Worker
|
86
|
+
def perform(name, count)
|
87
|
+
# do something
|
88
|
+
end
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
Note that the convention is to use `app/workers` as the directory for your workers.
|
93
|
+
|
94
|
+
## Testing
|
95
|
+
|
96
|
+
See [Sidekiq testing documentation](https://github.com/mperham/sidekiq/wiki/Testing)
|
97
|
+
on how to test Sidekiq workers.
|
98
|
+
|
99
|
+
Because of the way we use middleware, you may see errors that indicate that
|
100
|
+
your job is called with the wrong number of arguments. To set up testing
|
101
|
+
correctly, replace `require 'sidekiq/testing'` with:
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
require 'govuk_sidekiq/testing'
|
105
|
+
```
|
39
106
|
|
40
107
|
## Licence
|
41
108
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk_sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elliot Crosby-McCullough
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|