This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(worker): "resque" support added
Resolves #41
- Loading branch information
Showing
14 changed files
with
253 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
module Drivers | ||
module Worker | ||
class Resque < Drivers::Worker::Base | ||
adapter :resque | ||
allowed_engines :resque | ||
output filter: [:process_count, :syslog, :workers, :queues] | ||
packages debian: 'redis-server', rhel: 'redis' | ||
|
||
def configure(context) | ||
add_resque_monit(context) | ||
end | ||
|
||
def after_deploy(context) | ||
(1..process_count).each do |process_number| | ||
context.execute "monit restart resque_#{app['shortname']}-#{process_number}" do | ||
retries 3 | ||
end | ||
end | ||
context.execute 'monit reload' | ||
end | ||
alias after_undeploy after_deploy | ||
|
||
private | ||
|
||
def add_resque_monit(context) | ||
app_shortname = app['shortname'] | ||
deploy_to = deploy_dir(app) | ||
output = out | ||
env = environment | ||
|
||
context.template File.join(node['monit']['basedir'], "resque_#{app_shortname}.monitrc") do | ||
mode '0640' | ||
source 'resque.monitrc.erb' | ||
variables application: app_shortname, out: output, deploy_to: deploy_to, environment: env | ||
end | ||
end | ||
|
||
def process_count | ||
[out[:process_count].to_i, 1].max | ||
end | ||
|
||
def environment | ||
framework = Drivers::Framework::Factory.build(app, node) | ||
app['environment'].merge(framework.out[:deploy_environment] || {}) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
require 'spec_helper' | ||
|
||
describe Drivers::Worker::Resque do | ||
it 'receives and exposes app and node' do | ||
driver = described_class.new(aws_opsworks_app, node) | ||
|
||
expect(driver.app).to eq aws_opsworks_app | ||
expect(driver.node).to eq node | ||
expect(driver.options).to eq({}) | ||
end | ||
|
||
it 'returns proper out data' do | ||
expect(described_class.new(aws_opsworks_app, node).out).to eq( | ||
process_count: 2, | ||
syslog: true, | ||
queues: 'test_queue' | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.