blazing-foreman 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.
- data/.gitignore +4 -0
- data/Gemfile +5 -0
- data/MIT-LICENSE +20 -0
- data/README.md +54 -0
- data/blazing-foreman.gemspec +23 -0
- data/lib/blazing-foreman.rb +8 -0
- data/lib/blazing-foreman/recipes/deploy_processes.rb +39 -0
- data/lib/blazing-foreman/recipes/restart_processes.rb +50 -0
- data/lib/blazing-foreman/version.rb +5 -0
- data/spec/deploy_processes_spec.rb +28 -0
- data/spec/restart_processes_spec.rb +30 -0
- metadata +107 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
|
@@ -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.
|
data/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Blazing Foreman
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
Foreman recipes for [blazing](http://github.com/effkay/blazing)
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
Add `gem 'blazing-foreman'` to your `Gemfile`
|
|
10
|
+
|
|
11
|
+
Usage
|
|
12
|
+
-----
|
|
13
|
+
|
|
14
|
+
Enable the recipes you want in your blazing configuration file. Options
|
|
15
|
+
can be provided in the recipe call or with the target method. Target
|
|
16
|
+
options have precedence over recipe options.
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
# Deploy the processes
|
|
20
|
+
#
|
|
21
|
+
# recipe :deploy_processes, [options]
|
|
22
|
+
#
|
|
23
|
+
# Options:
|
|
24
|
+
#
|
|
25
|
+
# :rails_env (specify the rails environment)
|
|
26
|
+
#
|
|
27
|
+
# Example:
|
|
28
|
+
|
|
29
|
+
recipe :deploy_processes, :rails_env => 'production'
|
|
30
|
+
|
|
31
|
+
# Restart the processes
|
|
32
|
+
#
|
|
33
|
+
# recipe :restart_processes, [options]
|
|
34
|
+
#
|
|
35
|
+
# Options:
|
|
36
|
+
#
|
|
37
|
+
# :rails_env (specify the rails environment)
|
|
38
|
+
#
|
|
39
|
+
# Example:
|
|
40
|
+
|
|
41
|
+
recipe :restart_processes, :rails_env => 'production'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Authors
|
|
45
|
+
-------
|
|
46
|
+
|
|
47
|
+
Daniel Farrell ([@danielfarrell][])
|
|
48
|
+
|
|
49
|
+
License
|
|
50
|
+
-------
|
|
51
|
+
|
|
52
|
+
See the [MIT-LICENSE file](https://github.com/danielfarrell/blazing-foreman/blob/master/MIT-LICENSE)
|
|
53
|
+
|
|
54
|
+
[@danielfarrell]: https://github.com/danielfarrell
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "blazing-foreman/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "blazing-foreman"
|
|
7
|
+
s.version = Blazing::Foreman::VERSION
|
|
8
|
+
s.authors = ["Daniel Farrell"]
|
|
9
|
+
s.email = ["danielfarrell76@gmail.com"]
|
|
10
|
+
s.homepage = "https://github.com/danielfarrell/blazing-foreman"
|
|
11
|
+
s.summary = %q{blazing recipes for deploying processes with foreman}
|
|
12
|
+
s.description = %q{blazing recipes for deploying processes with foreman}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "blazing-foreman"
|
|
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 "activesupport"
|
|
22
|
+
s.add_dependency "foreman"
|
|
23
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'blazing/recipe'
|
|
2
|
+
require 'active_support/core_ext/object/blank'
|
|
3
|
+
|
|
4
|
+
class Blazing::Recipe::DeployProcesses < Blazing::Recipe
|
|
5
|
+
|
|
6
|
+
def initialize(options={})
|
|
7
|
+
super
|
|
8
|
+
@options.merge! :format => 'upstart', :location => '/etc/init'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def run(target_options = {})
|
|
12
|
+
super target_options
|
|
13
|
+
|
|
14
|
+
info 'deploying processes'
|
|
15
|
+
system "#{sudo} foreman export #{arguments}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def arguments
|
|
21
|
+
options.delete_if {|k, v| v.blank?}
|
|
22
|
+
args = ["#{options[:format]} #{options[:location]}"]
|
|
23
|
+
args << "-f #{options[:procfile]}" if options[:procfile]
|
|
24
|
+
args << "-a #{options[:app]}" if options[:app]
|
|
25
|
+
args << "-u #{options[:user]}" if options[:user]
|
|
26
|
+
args << "-d #{options[:directory]}" if options[:directory]
|
|
27
|
+
args << "-e #{options[:env]}" if options[:env]
|
|
28
|
+
args << "-l #{options[:log]}" if options[:log]
|
|
29
|
+
args << "-p #{options[:port]}" if options[:port]
|
|
30
|
+
args << "-c #{options[:concurrency]}" if options[:concurrency]
|
|
31
|
+
args << "-t #{options[:template]}" if options[:template]
|
|
32
|
+
args.join(' ')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def sudo
|
|
36
|
+
options[:sudo] || 'sudo'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "blazing/recipe"
|
|
2
|
+
require "foreman/procfile"
|
|
3
|
+
|
|
4
|
+
class Blazing::Recipe::RestartProcesses < Blazing::Recipe
|
|
5
|
+
|
|
6
|
+
def run(target_options = {})
|
|
7
|
+
super target_options
|
|
8
|
+
|
|
9
|
+
info "restarting processes"
|
|
10
|
+
if complex_restart?
|
|
11
|
+
processes.each do |process|
|
|
12
|
+
restart = restart_command process
|
|
13
|
+
system "#{sudo} initctl start #{application}-#{process} || #{sudo} initctl #{restart} #{application}-#{process}"
|
|
14
|
+
end
|
|
15
|
+
else
|
|
16
|
+
system "#{sudo} initctl start #{application} || #{sudo} initctl restart #{application}"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def application
|
|
23
|
+
options[:app] || pwd
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def pwd
|
|
27
|
+
Dir.pwd.split('/').last
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def complex_restart?
|
|
31
|
+
!options[:reload].nil?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def restart_command(process)
|
|
35
|
+
options[:reload].include?(process) ? "reload" : "restart"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def procfile
|
|
39
|
+
options[:procfile] || "Procfile"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def processes
|
|
43
|
+
Foreman::Procfile.new(procfile).entries.keys
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def sudo
|
|
47
|
+
options[:sudo] || 'sudo'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'blazing-foreman/recipes/deploy_processes'
|
|
2
|
+
|
|
3
|
+
describe Blazing::Recipe::DeployProcesses do
|
|
4
|
+
|
|
5
|
+
it 'is a blazing recipe' do
|
|
6
|
+
Blazing::Recipe::DeployProcesses.superclass.should be Blazing::Recipe
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe 'run' do
|
|
10
|
+
|
|
11
|
+
before :each do
|
|
12
|
+
@recipe = Blazing::Recipe::DeployProcesses.new
|
|
13
|
+
@recipe.stub(:info)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should call to foreman export by default' do
|
|
17
|
+
@recipe.should_receive(:system).with("sudo foreman export upstart /etc/init")
|
|
18
|
+
@recipe.run
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should include all options when passed' do
|
|
22
|
+
@recipe.should_receive(:system).with("rvmsudo foreman export upstart /etc/init -f Procfile2 -a testing -u bob -d /var/www/testing -e test_env -l /var/www/testing/log -p 3000 -c web:2 -t custom")
|
|
23
|
+
@recipe.run :sudo =>'rvmsudo', :app => 'testing', :user => 'bob', :procfile => 'Procfile2', :env => 'test_env', :directory => '/var/www/testing', :log => '/var/www/testing/log', :port => 3000, :concurrency => 'web:2', :template => 'custom'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'blazing-foreman/recipes/restart_processes'
|
|
2
|
+
|
|
3
|
+
describe Blazing::Recipe::RestartProcesses do
|
|
4
|
+
|
|
5
|
+
it 'is a blazing recipe' do
|
|
6
|
+
Blazing::Recipe::RestartProcesses.superclass.should be Blazing::Recipe
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe 'run' do
|
|
10
|
+
|
|
11
|
+
before :each do
|
|
12
|
+
@recipe = Blazing::Recipe::RestartProcesses.new(:app => 'testing')
|
|
13
|
+
@recipe.stub(:info)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should call upstart for start or restart by default' do
|
|
17
|
+
@recipe.should_receive(:system).with("sudo initctl start testing || sudo initctl restart testing")
|
|
18
|
+
@recipe.run
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should reload processes passed for reload' do
|
|
22
|
+
procfile = double("procfile", :entries => {'web' => 'unicorn'})
|
|
23
|
+
Foreman::Procfile.should_receive(:new) { procfile }
|
|
24
|
+
@recipe.should_receive(:system).with("sudo initctl start testing-web || sudo initctl reload testing-web")
|
|
25
|
+
@recipe.run :reload => ['web']
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: blazing-foreman
|
|
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-01-07 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: activesupport
|
|
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: foreman
|
|
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 recipes for deploying processes with foreman
|
|
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-foreman.gemspec
|
|
74
|
+
- lib/blazing-foreman.rb
|
|
75
|
+
- lib/blazing-foreman/recipes/deploy_processes.rb
|
|
76
|
+
- lib/blazing-foreman/recipes/restart_processes.rb
|
|
77
|
+
- lib/blazing-foreman/version.rb
|
|
78
|
+
- spec/deploy_processes_spec.rb
|
|
79
|
+
- spec/restart_processes_spec.rb
|
|
80
|
+
homepage: https://github.com/danielfarrell/blazing-foreman
|
|
81
|
+
licenses: []
|
|
82
|
+
post_install_message:
|
|
83
|
+
rdoc_options: []
|
|
84
|
+
require_paths:
|
|
85
|
+
- lib
|
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
|
+
none: false
|
|
88
|
+
requirements:
|
|
89
|
+
- - ! '>='
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
none: false
|
|
94
|
+
requirements:
|
|
95
|
+
- - ! '>='
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0'
|
|
98
|
+
requirements: []
|
|
99
|
+
rubyforge_project: blazing-foreman
|
|
100
|
+
rubygems_version: 1.8.23
|
|
101
|
+
signing_key:
|
|
102
|
+
specification_version: 3
|
|
103
|
+
summary: blazing recipes for deploying processes with foreman
|
|
104
|
+
test_files:
|
|
105
|
+
- spec/deploy_processes_spec.rb
|
|
106
|
+
- spec/restart_processes_spec.rb
|
|
107
|
+
has_rdoc:
|