forked from pedroaxl/opsworks-resque
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pedroaxl#2 from bargeapp/master
use opsworks native deploy_to and rails_env
- Loading branch information
Showing
8 changed files
with
101 additions
and
45 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 was deleted.
Oops, something went wrong.
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 @@ | ||
default[:resque][:workers] = { '*' => 1 } |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
service 'resque' do | ||
action [:stop, :start] | ||
provider Chef::Provider::Service::Upstart | ||
node[:deploy].each do |application, deploy| | ||
service "resque-#{application}" do | ||
action [:stop, :start] | ||
provider Chef::Provider::Service::Upstart | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Cookbook Name:: opsworks-resque | ||
# Recipe:: default | ||
# | ||
# Copyright (C) 2014 PEDRO AXELRUD | ||
# | ||
# All rights reserved - Do Not Redistribute | ||
# | ||
|
||
node[:deploy].each do |application, deploy| | ||
|
||
Chef::Log.info("Configuring resque for application #{application}") | ||
|
||
template "/etc/init/resque-#{application}.conf" do | ||
source "resque.conf.erb" | ||
mode '0644' | ||
variables deploy: deploy | ||
end | ||
|
||
settings = node[:resque][application] | ||
# configure rails_env in case of non-rails app | ||
rack_env = deploy[:rails_env] || settings[:rack_env] || settings[:rails_env] | ||
settings[:workers].each do |queue, quantity| | ||
|
||
quantity.times do |idx| | ||
idx = idx + 1 # make index 1-based | ||
template "/etc/init/resque-#{application}-#{idx}.conf" do | ||
source "resque-n.conf.erb" | ||
mode '0644' | ||
variables application: application, rack_env: rack_env, deploy: deploy, queue: queue, instance: idx | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
#!upstart | ||
description "Resque worker <%= @instance %> <%= @queue %>" | ||
respawn | ||
start on starting resque-<%= @application %> | ||
stop on stopping resque-<%= @application %> | ||
|
||
start on starting resque | ||
stop on stopping resque | ||
env QUEUE=<%= @queue %> | ||
env RACK_ENV=<%= @rack_env %> | ||
env TERM_CHILD=1 | ||
|
||
exec su - deploy -c 'cd <%= node['resque']['path'] %>; QUEUE=<%= @queue %> VERBOSE=1 RAILS_ENV=<%= node['resque']['rails_env'] %> bundle exec rake resque:work >> /var/log/resque/<%= @instance %>.log 2>&1' | ||
chdir <%= @deploy[:deploy_to] %>/current | ||
|
||
exec sudo -u deploy -E -- bundle exec rake resque:work >> /var/log/resque/<%= @application %>-<%= @instance %>.log 2>&1 |
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