blazing-unicorn 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+
4
+ gem 'rake'
5
+ gem 'rspec'
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Daniel Farrell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ Blazing Unicorn
2
+ ===============
3
+
4
+ Unicorn recipe for [blazing](http://github.com/effkay/blazing)
5
+
6
+ If you run your applications with [unicorn](http://unicorn.bogomips.org/) this lets you
7
+ do a rolling restart after a deployment.
8
+
9
+
10
+ Installation
11
+ ------------
12
+
13
+ Add `gem 'blazing-unicorn'` to your `Gemfile`
14
+
15
+ Usage
16
+ -----
17
+
18
+ Enable the recipes you want in your blazing configuration file. Options
19
+ can be provided in the recipe call or with the target method. Target
20
+ options have precedence over recipe options.
21
+
22
+ ```ruby
23
+ # Restart unicorn
24
+ #
25
+ # recipe :rolling_restart, [options]
26
+ #
27
+ # Options:
28
+ #
29
+ # :pid_file (Set the location of the pid file, default: tmp/pids/unicorn.pid)
30
+ #
31
+ # Example:
32
+
33
+ recipe :rolling_restart
34
+ ```
35
+
36
+ Authors
37
+ -------
38
+
39
+ Daniel Farrell ([@danielfarrell][])
40
+
41
+ License
42
+ -------
43
+
44
+ See the [MIT-LICENSE file](https://github.com/danielfarrell/blazing-unicorn/blob/master/MIT-LICENSE)
45
+
46
+ [@danielfarrell]: https://github.com/danielfarrell
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "blazing-unicorn/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "blazing-unicorn"
7
+ s.version = Blazing::Unicorn::VERSION
8
+ s.authors = ["Daniel Farrell"]
9
+ s.email = ["danielfarrell76@gmail.com"]
10
+ s.homepage = "https://github.com/danielfarrell/blazing-unicorn"
11
+ s.summary = %q{blazing recipe for rolling restarts with unicorn}
12
+ s.description = %q{blazing recipe for rolling restarts with unicorn}
13
+
14
+ s.rubyforge_project = "blazing-unicorn"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency "blazing", '>= 0.2.9'
21
+ s.add_dependency "unicorn"
22
+ s.add_dependency "activesupport"
23
+ end
@@ -0,0 +1,7 @@
1
+ require "blazing-unicorn/version"
2
+ require "blazing-unicorn/recipes/rolling_restart"
3
+
4
+ module Blazing
5
+ module Unicorn
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ require "blazing/recipe"
2
+
3
+ class Blazing::Recipe::RollingRestart < Blazing::Recipe
4
+
5
+ def run(target_options = {})
6
+ super target_options
7
+
8
+ info "restarting unicorn"
9
+ Process.kill("USR2", pid)
10
+ end
11
+
12
+ private
13
+
14
+ def pid
15
+ File.read(pid_file).to_i
16
+ end
17
+
18
+ def pid_file
19
+ options[:pid_file] || "tmp/pids/unicorn.pid"
20
+ end
21
+
22
+ end
@@ -0,0 +1,5 @@
1
+ module Blazing
2
+ module Unicorn
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ require 'blazing-unicorn/recipes/rolling_restart'
2
+
3
+ describe Blazing::Recipe::RollingRestart do
4
+
5
+ it 'is a blazing recipe' do
6
+ Blazing::Recipe::RollingRestart.superclass.should be Blazing::Recipe
7
+ end
8
+
9
+ describe 'run' do
10
+
11
+ before :each do
12
+ @pid = 123
13
+ Process.should_receive(:kill).with("USR2", @pid)
14
+ @recipe = Blazing::Recipe::RollingRestart.new
15
+ @recipe.stub(:info)
16
+ end
17
+
18
+ it 'should call send USR2 signal to the pid' do
19
+ @recipe.should_receive(:pid).and_return(@pid)
20
+ @recipe.run
21
+ end
22
+
23
+ it 'should allow custom pid file' do
24
+ @recipe.should_receive(:pid).and_return(@pid)
25
+ pid_file = 'tmp/unicorn.pid'
26
+ @recipe.run :pid_file => pid_file
27
+ @recipe.send(:pid_file).should eq(pid_file)
28
+ end
29
+
30
+ end
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blazing-unicorn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Farrell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: blazing
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.9
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.9
30
+ - !ruby/object:Gem::Dependency
31
+ name: unicorn
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: activesupport
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: blazing recipe for rolling restarts with unicorn
63
+ email:
64
+ - danielfarrell76@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - MIT-LICENSE
72
+ - README.md
73
+ - blazing-unicorn.gemspec
74
+ - lib/blazing-unicorn.rb
75
+ - lib/blazing-unicorn/recipes/rolling_restart.rb
76
+ - lib/blazing-unicorn/version.rb
77
+ - spec/rolling_restart_spec.rb
78
+ homepage: https://github.com/danielfarrell/blazing-unicorn
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project: blazing-unicorn
98
+ rubygems_version: 1.8.23
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: blazing recipe for rolling restarts with unicorn
102
+ test_files:
103
+ - spec/rolling_restart_spec.rb