blue-resque 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.swp
19
+ *.swo
20
+ README.html
21
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blue-resque.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Josh Sharpe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Blue::Resque
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'blue-resque'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install blue-resque
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blue/resque/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "blue-resque"
8
+ spec.version = Blue::Resque::VERSION
9
+ spec.authors = ["Josh Sharpe"]
10
+ spec.email = ["josh.m.sharpe@gmail.com"]
11
+ spec.description = %q{A Resque plugin for the Blue deployment framework}
12
+ spec.summary = %q{Provides monitoring and controls for resque workers}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,30 @@
1
+ module Blue
2
+ module Resque
3
+ module Capistrano
4
+ module Integration
5
+
6
+ def self.load(capistrano_config)
7
+ capistrano_config.load do
8
+
9
+ namespace :blue do
10
+ namespace :resque do
11
+ desc "Trigger Resque restarts"
12
+ task :restart do
13
+ run %(find #{File.join(Blue.shared_path, 'pids')} -name resque_worker_*.pid -exec bash -c 'kill -QUIT $(cat $1) ; rm $1' _ {} \\\;)
14
+ sudo "monit -g resque restart"
15
+ end
16
+ end
17
+ end
18
+
19
+ after 'deploy:create_symlink', 'blue:resque:restart'
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ if Capistrano::Configuration.instance
28
+ Blue::Resque::Capistrano::Integration.load(Capistrano::Configuration.instance)
29
+ end
30
+
@@ -0,0 +1,5 @@
1
+ module Blue
2
+ module Resque
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,45 @@
1
+ require "blue/resque/version"
2
+ require "blue/resque/capistrano/integration"
3
+
4
+ module Blue
5
+ module Resque
6
+
7
+ Blue::Gems.require('blue-resque')
8
+
9
+ def self.configure
10
+ Blue.configure({
11
+ :resque => {
12
+ :num_workers => 1
13
+ }
14
+ })
15
+ end
16
+
17
+ def self.worker_pid_path(worker_id)
18
+ "#{Blue.shared_path}/pids/resque_worker_#{worker_id}.pid"
19
+ end
20
+
21
+ def resque_monitoring
22
+ if Blue.const_defined?(:Monit)
23
+ file "/etc/monit/conf.d/resque.conf",
24
+ :ensure => :present,
25
+ :mode => '700',
26
+ :backup => false,
27
+ :content => template(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'monit.conf.erb'), binding),
28
+ :notify => service('monit')
29
+
30
+ elsif Blue.const_defined?(:God)
31
+ # Define this yo'self homie.
32
+ end
33
+ end
34
+
35
+ def self.included(klass)
36
+ klass.add_role(:resque)
37
+ klass.class_eval do
38
+ recipe :resque_monitoring
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ Blue::Resque.configure
45
+
@@ -0,0 +1,9 @@
1
+ <% Blue.config.resque.num_workers.times do |i| %>
2
+ check process resque_worker_<%= i %>
3
+ with pidfile <%= Blue::Resque.worker_pid_path(i) %>
4
+ start program = "/bin/sh -c 'cd <%= Blue.rails_current %> ; bundle exec rake environment resque:work RAILS_ENV=<%= Blue.env %> QUEUE=* VERBOSE=1 PIDFILE=<%= Blue::Resque.worker_pid_path(i) %> & >> log/resque_worker_<%= i %>.log 2>&1'" as uid <%= Blue.config.user %> and gid <%= Blue.config.group %> with timeout 60 seconds
5
+ stop program = "/bin/sh -c 'cd <%= Blue.rails_current %> && kill -QUIT $(cat <%= Blue::Resque.worker_pid_path(i) %>) ; rm -f <%= Blue::Resque.worker_pid_path(i) %> ; exit 0;'"
6
+ <% if Blue.config.resque.restart_mb %>if totalmem is greater than <%= Blue.config.resque.restart_mb %> MB for 5 cycles then restart<% end %>
7
+ group resque
8
+ <% end %>
9
+
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blue-resque
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Josh Sharpe
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-05-24 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: bundler
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 9
29
+ segments:
30
+ - 1
31
+ - 3
32
+ version: "1.3"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rake
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ description: A Resque plugin for the Blue deployment framework
50
+ email:
51
+ - josh.m.sharpe@gmail.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - .gitignore
60
+ - Gemfile
61
+ - LICENSE.txt
62
+ - README.md
63
+ - Rakefile
64
+ - blue-resque.gemspec
65
+ - lib/blue/resque.rb
66
+ - lib/blue/resque/capistrano/integration.rb
67
+ - lib/blue/resque/version.rb
68
+ - templates/monit.conf.erb
69
+ homepage: ""
70
+ licenses:
71
+ - MIT
72
+ post_install_message:
73
+ rdoc_options: []
74
+
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.8.24
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Provides monitoring and controls for resque workers
102
+ test_files: []
103
+