Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
feat(worker): add good_job
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnofoolin authored and ajgon committed Feb 9, 2022
1 parent 35d9f72 commit af98d67
Show file tree
Hide file tree
Showing 13 changed files with 578 additions and 14 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,27 @@ jobs:
- name: Run unit tests
run: |
chef exec bundle exec rspec
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- uses: nelonoel/branch-name@v1.0.1
- id: set-matrix
uses: JoshuaTheMiller/conditional-build-matrix@0.0.1
with:
filter: '[?runOn==`${{ env.BRANCH_NAME }}` || runOn==`always`]'
integration:
needs: prepare-matrix
runs-on: ubuntu-18.04
env:
CHEF_LICENSE: accept
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
strategy:
fail-fast: false
matrix:
instance:
- default-ubuntu-1804
- all-options-ubuntu-1804
- default-with-shoryuken-and-fullstaq-ubuntu-1804
- http-unicorn-apache-hanami-resque-ubuntu-1804
- s3-thin-nginx-padrino-delayed-job-ubuntu-1804
- nullified-ubuntu-1804
- maximum-override-ubuntu-1804

matrix: ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
steps:
- name: Add chef repo
uses: myci-actions/add-deb-repo@10
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/matrix_includes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{
"instance": "default-ubuntu-1804",
"runOn": "always"
}, {
"instance": "all-options-ubuntu-1804",
"runOn": "always"
}, {
"instance": "default-with-shoryuken-and-fullstaq-ubuntu-1804",
"runOn": "always"
}, {
"instance": "http-unicorn-apache-hanami-resque-ubuntu-1804",
"runOn": "always"
}, {
"instance": "s3-thin-nginx-padrino-delayed-job-ubuntu-1804",
"runOn": "master"
}, {
"instance": "nullified-ubuntu-1804",
"runOn": "always"
}, {
"instance": "maximum-override-ubuntu-1804",
"runOn": "always"
}
]
6 changes: 6 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ suites:
logrotate_template_owner: 'root'
port: 8080
ssl_port: 8443
worker:
adapter: 'good_job'
process_count: 1
queues:
- default
- mailers
yet_another_project:
appserver:
adapter: 'unicorn'
Expand Down
9 changes: 7 additions & 2 deletions docs/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,11 @@ as well (notice that `node['deploy'][<application_shortname>]` logic doesn't app

### worker

Worker configuration. Currently sidekiq, delayed_job, resque, shoryuken.
Worker configuration. Currently sidekiq, delayed_job, resque, shoryuken, good_job.

- `app['worker']['adapter']`
- **Default:** `null`
- **Supported values:** `sidekiq`, `delayed_job`, `resque`, `shoryuken` and `null`.
- **Supported values:** `sidekiq`, `delayed_job`, `resque`, `shoryuken`, `good_job`, and `null`.
- If worker is needed, here it can be set up and configured. `null` means no worker installed.

- `app['worker']['monit_template_cookbook']`
Expand Down Expand Up @@ -722,6 +722,11 @@ Worker configuration. Currently sidekiq, delayed_job, resque, shoryuken.
- **Default**: `false`
- Configures piping shoryuken runner log output to syslog via `logger`

#### good_job

- `app['worker']['queues']`
- Array of queues which should be processed by good_job


## Logrotate Attributes

Expand Down
1 change: 1 addition & 0 deletions docs/support.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
- [resque](https://resque.github.io/)
- [sidekiq](http://sidekiq.org/)
- [shoryuken](https://github.com/phstc/shoryuken)
- [good_job](https://github.com/bensheldon/good_job)
25 changes: 25 additions & 0 deletions libraries/drivers_worker_good_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Drivers
module Worker
class GoodJob < Drivers::Worker::Base
adapter :good_job
allowed_engines :good_job
output filter: %i[process_count syslog queues]
packages :monit

def after_deploy
restart_monit
end
alias after_undeploy after_deploy

def settings
super.merge(queues: node['deploy'][app['shortname']][driver_type]['queues'] || '')
end

def configure
add_worker_monit
end
end
end
end
21 changes: 21 additions & 0 deletions spec/unit/libraries/drivers_worker_good_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require 'spec_helper'

describe Drivers::Worker::GoodJob do
let(:driver) { described_class.new(dummy_context(node), aws_opsworks_app) }

it 'receives and exposes app and node' do
expect(driver.app).to eq aws_opsworks_app
expect(driver.send(:node)).to eq node
expect(driver.options).to eq({})
end

it 'has the correct driver_type' do
expect(driver.driver_type).to eq('worker')
end

it 'returns proper out data' do
expect(driver.out).to eq(process_count: 2, syslog: true, queues: 'test_queue')
end
end
Loading

0 comments on commit af98d67

Please sign in to comment.