matross 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +37 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +27 -0
- data/Rakefile +1 -0
- data/VERSION +1 -0
- data/lib/matross.rb +6 -0
- data/lib/matross/base.rb +9 -0
- data/lib/matross/foreman.rb +54 -0
- data/lib/matross/local_assets.rb +26 -0
- data/lib/matross/nginx.rb +18 -0
- data/lib/matross/templates/foreman/process.conf.erb +6 -0
- data/lib/matross/templates/nginx/nginx_virtual_host_conf.erb +31 -0
- data/lib/matross/templates/unicorn/unicorn.rb.erb +25 -0
- data/lib/matross/unicorn.rb +24 -0
- data/lib/matross/version.rb +3 -0
- data/matross.gemspec +26 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Mjc1ZTA0NDY3NTgzOTE4ODFlNmU2NDM2ODkxYjBmOGIwMmYxYTg4NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjFkM2Q0OGMwNTZiMmJkMGRiNzliMjYwYTcwNTZiZjcyOGNhZDA1Nw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjA2MjczMGRjMDNjZDM5M2ZiOGIwMDRjMmNlYTY3NjM1NmE5MWJhODgxYmQ0
|
10
|
+
ZDM3MGZkMDhkMWM4YWY5ZjA5MzI0MzEzYjIxM2VkM2E1YWM2OTU2NWMzZWEy
|
11
|
+
MDBjODgxYmIyZWNmOTM0MmUxNzVhYmNhMjVlNGJjYWMzNzg1MmU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MjZmMzllNzlkMjMxMjE1MGRmMjdjZjMxYjdkMmZiZTA5YmQ4MWE2YjdlYWVh
|
14
|
+
MjA3YTgyNTc5YjI4NzA3MzdhYWEzNmM3YjAyYjUyMmY5MjcyZmJlYWI4MGY2
|
15
|
+
ZWZjNzc5ZjhlNTVhZThiNmZlZTFmODg2ZWJmOTU5MDBjMjQ0Zjk=
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
InstalledFiles
|
7
|
+
lib/bundler/man
|
8
|
+
pkg
|
9
|
+
rdoc
|
10
|
+
spec/reports
|
11
|
+
test/tmp
|
12
|
+
test/version_tmp
|
13
|
+
tmp
|
14
|
+
|
15
|
+
# YARD artifacts
|
16
|
+
.yardoc
|
17
|
+
_yardoc
|
18
|
+
doc/
|
19
|
+
|
20
|
+
# rcov generated
|
21
|
+
coverage
|
22
|
+
coverage.data
|
23
|
+
|
24
|
+
# rdoc generated
|
25
|
+
rdoc
|
26
|
+
|
27
|
+
# yard generated
|
28
|
+
doc
|
29
|
+
.yardoc
|
30
|
+
|
31
|
+
# bundler
|
32
|
+
.bundle
|
33
|
+
|
34
|
+
# jeweler generated
|
35
|
+
pkg
|
36
|
+
|
37
|
+
Gemfile.lock
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p448
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Innvent | Innovation & Venturing
|
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,27 @@
|
|
1
|
+
# matross
|
2
|
+
|
3
|
+
## Usage
|
4
|
+
|
5
|
+
Put matross in the `:development` group of your `Gemfile`:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
group :development do
|
9
|
+
gem 'matross', :git => 'git://github.com/innvent/matross.git'
|
10
|
+
end
|
11
|
+
```
|
12
|
+
|
13
|
+
Run `bundle exec capify .` in the project root folder:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ bundle exec capify .
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
## What's inside?
|
21
|
+
|
22
|
+
We made a bunch of additions and customizations. Below we list the most relevant ones.
|
23
|
+
|
24
|
+
* **Foreman by default**:
|
25
|
+
* **Custom foreman upstart template**: we use a custom upstart template, that enables `console log`, allowing `logrotate` to work properly.
|
26
|
+
* **User template overwrite**:
|
27
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/lib/matross.rb
ADDED
data/lib/matross/base.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
def template(from, to)
|
2
|
+
override_template = File.join(Dir.pwd, 'config/matross', from)
|
3
|
+
if File.exist?(override_template)
|
4
|
+
erb = File.read(override_template)
|
5
|
+
else
|
6
|
+
erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
|
7
|
+
end
|
8
|
+
put ERB.new(erb).result(binding), to
|
9
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
_cset(:foreman_user) { user }
|
2
|
+
_cset :foreman_bin, "bundle exec foreman"
|
3
|
+
|
4
|
+
namespace :foreman do
|
5
|
+
|
6
|
+
desc "Pre-setup, creates the shared upstart folder"
|
7
|
+
task :pre_setup do
|
8
|
+
run "mkdir -p #{shared_path}/upstart"
|
9
|
+
end
|
10
|
+
before "foreman:setup", "foreman:pre_setup"
|
11
|
+
|
12
|
+
desc "Merges all partial Procfiles"
|
13
|
+
task :setup do
|
14
|
+
run "cat #{shared_path}/Procfile.* > #{shared_path}/Procfile"
|
15
|
+
run "rm #{shared_path}/Procfile.*"
|
16
|
+
end
|
17
|
+
before "foreman:export", "foreman:setup"
|
18
|
+
|
19
|
+
desc "Export the Procfile to Ubuntu's upstart scripts"
|
20
|
+
task :export, :roles => [:app, :dj] do
|
21
|
+
matross_path = "#{shared_path}/matross"
|
22
|
+
run "mkdir -p #{matross_path}"
|
23
|
+
upload File.expand_path("../templates/foreman", __FILE__), matross_path,
|
24
|
+
:via => :scp, :recursive => true
|
25
|
+
|
26
|
+
run "cd #{current_path} && #{foreman_bin} export upstart #{shared_path}/upstart "\
|
27
|
+
"-f #{current_path}/Procfile "\
|
28
|
+
"-a #{application} "\
|
29
|
+
"-u #{foreman_user} "\
|
30
|
+
"-l #{shared_path}/log "\
|
31
|
+
"-t #{matross_path}/foreman"
|
32
|
+
run "cd #{shared_path}/upstart && #{sudo} cp * /etc/init/"
|
33
|
+
end
|
34
|
+
before "deploy:restart", "foreman:export"
|
35
|
+
|
36
|
+
desc "Symlink configuration scripts"
|
37
|
+
task :symlink, :roles => [:app, :dj], :except => { :no_release => true } do
|
38
|
+
run "ln -nfs #{shared_path}/Procfile #{release_path}/Procfile"
|
39
|
+
end
|
40
|
+
after "foreman:setup", "foreman:symlink"
|
41
|
+
|
42
|
+
desc "Restart services"
|
43
|
+
task :restart, :roles => [:app, :dj] do
|
44
|
+
run "#{sudo} start #{application} || #{sudo} restart #{application}"
|
45
|
+
end
|
46
|
+
after "deploy:restart", "foreman:restart"
|
47
|
+
|
48
|
+
desc "Remove upstart scripts"
|
49
|
+
task :remove, :roles => [:app, :dj] do
|
50
|
+
run "cd #{shared_path}/upstart && rm -f Procfile*"
|
51
|
+
run "cd /etc/init/ && #{sudo} rm #{application}*"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
load "deploy/assets"
|
2
|
+
|
3
|
+
namespace :deploy do
|
4
|
+
|
5
|
+
namespace :assets do
|
6
|
+
|
7
|
+
desc "Run Rails asset pipeline locally"
|
8
|
+
task :precompile, :roles => :web do
|
9
|
+
run_locally <<-CMD.gsub(/^\s+/, '')
|
10
|
+
RAILS_ENV=#{rails_env.to_s.shellescape} #{rake} assets:clean &&
|
11
|
+
RAILS_ENV=#{rails_env.to_s.shellescape} #{rake} assets:precompile &&
|
12
|
+
cd public && tar -jcf assets.tar.bz2 assets
|
13
|
+
CMD
|
14
|
+
top.upload "public/assets.tar.bz2", "#{shared_path}", :via => :scp
|
15
|
+
run "cd #{shared_path} && tar -jxf assets.tar.bz2 && rm assets.tar.bz2"
|
16
|
+
|
17
|
+
# Clean up temporary local assets
|
18
|
+
run_locally <<-CMD.gsub(/^\s+/, '')
|
19
|
+
rm public/assets.tar.bz2 &&
|
20
|
+
RAILS_ENV=#{rails_env.to_s.shellescape} #{rake} assets:clean
|
21
|
+
CMD
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
namespace :nginx do
|
2
|
+
|
3
|
+
desc "Setup application in nginx"
|
4
|
+
task :setup, :roles => :web do
|
5
|
+
template "nginx/nginx_virtual_host_conf.erb", "/tmp/#{application}"
|
6
|
+
run "#{sudo} mv /tmp/#{application} /etc/nginx/sites-available/#{application}"
|
7
|
+
run "#{sudo} ln -fs /etc/nginx/sites-available/#{application} /etc/nginx/sites-enabled/#{application}"
|
8
|
+
run "mkdir -p #{shared_path}/sockets"
|
9
|
+
end
|
10
|
+
after "deploy:setup", "nginx:setup"
|
11
|
+
|
12
|
+
desc "Reload nginx configuration"
|
13
|
+
task :reload, :roles => :web do
|
14
|
+
run "#{sudo} /etc/init.d/nginx reload"
|
15
|
+
end
|
16
|
+
after "deploy:setup", "nginx:reload"
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
console log
|
2
|
+
start on starting <%= app %>-<%= name %>
|
3
|
+
stop on stopping <%= app %>-<%= name %>
|
4
|
+
respawn
|
5
|
+
|
6
|
+
exec su - <%= user %> -c 'cd <%= engine.root %>; export PORT=<%= port %>;<% engine.env.each_pair do |var,env| %> export <%= var.upcase %>=<%= shell_quote(env) %>; <% end %> <%= process.command %>'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
upstream <%= application %> {
|
2
|
+
server unix:/tmp/unicorn.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80 default_server;
|
7
|
+
client_max_body_size 50m;
|
8
|
+
server_name <%= server_name %>;
|
9
|
+
|
10
|
+
keepalive_timeout 5;
|
11
|
+
root <%= "#{deploy_to}/current/public" %>;
|
12
|
+
try_files $uri @<%= application %>;
|
13
|
+
|
14
|
+
location @<%= application %> {
|
15
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
16
|
+
proxy_set_header Host $http_host;
|
17
|
+
proxy_redirect off;
|
18
|
+
proxy_pass http://<%= application %>;
|
19
|
+
}
|
20
|
+
|
21
|
+
location ~ ^/(assets)/ {
|
22
|
+
gzip_static on;
|
23
|
+
expires max;
|
24
|
+
add_header Cache-Control public;
|
25
|
+
}
|
26
|
+
|
27
|
+
error_page 500 502 504 /500.html;
|
28
|
+
location = /500.html {
|
29
|
+
root /home/ubuntu/vandal/current/public;
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
app_path = "<%= current_path %>"
|
2
|
+
|
3
|
+
working_directory "#{app_path}"
|
4
|
+
pid "#{app_path}/tmp/pids/unicorn.pid"
|
5
|
+
stderr_path "#{app_path}/log/unicorn.log"
|
6
|
+
stdout_path "#{app_path}/log/unicorn.log"
|
7
|
+
|
8
|
+
listen "/tmp/unicorn.sock"
|
9
|
+
worker_processes <%= unicorn_workers %>
|
10
|
+
timeout 60
|
11
|
+
preload_app true
|
12
|
+
|
13
|
+
before_fork do |server, worker|
|
14
|
+
if defined?(ActiveRecord::Base)
|
15
|
+
ActiveRecord::Base.connection.disconnect!
|
16
|
+
end
|
17
|
+
|
18
|
+
sleep 1
|
19
|
+
end
|
20
|
+
|
21
|
+
after_fork do |server, worker|
|
22
|
+
if defined?(ActiveRecord::Base)
|
23
|
+
ActiveRecord::Base.establish_connection
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
_cset(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
|
2
|
+
_cset(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
|
3
|
+
_cset :unicorn_workers, 1
|
4
|
+
|
5
|
+
namespace :unicorn do
|
6
|
+
|
7
|
+
desc "Initial Setup"
|
8
|
+
task :setup, :roles => :app do
|
9
|
+
run "mkdir -p #{shared_path}/config"
|
10
|
+
template "unicorn/unicorn.rb.erb", unicorn_config
|
11
|
+
end
|
12
|
+
after "deploy:setup", "unicorn:setup"
|
13
|
+
|
14
|
+
desc "Writes the unicorn part of the Procfile"
|
15
|
+
task :procfile, :roles => :app do
|
16
|
+
procfile_template = <<-EOF.gsub(/^\s+/, '')
|
17
|
+
web: bundle exec unicorn -c <%= unicorn_config %> -E <%= rails_env %>
|
18
|
+
EOF
|
19
|
+
procfile = ERB.new(procfile_template, nil, '-')
|
20
|
+
put procfile.result(binding), "#{shared_path}/Procfile.app"
|
21
|
+
end
|
22
|
+
after "foreman:pre_setup", "unicorn:procfile"
|
23
|
+
|
24
|
+
end
|
data/matross.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "matross/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "matross"
|
8
|
+
spec.version = Matross::VERSION
|
9
|
+
spec.authors = ["Artur Rodrigues" , "Joao Sa"]
|
10
|
+
spec.email = ["arturhoo@gmail.com", "me@joaomsa.com"]
|
11
|
+
spec.description = %q{Our collection of opnionated Capistrano recipes}
|
12
|
+
spec.summary = %q{Our collection of opnionated Capistrano recipes}
|
13
|
+
spec.homepage = "https://github.com/innvent/matross"
|
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
|
+
|
23
|
+
spec.add_dependency "capistrano", "~> 2.15.5"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: matross
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artur Rodrigues
|
8
|
+
- Joao Sa
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: capistrano
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.15.5
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.15.5
|
42
|
+
description: Our collection of opnionated Capistrano recipes
|
43
|
+
email:
|
44
|
+
- arturhoo@gmail.com
|
45
|
+
- me@joaomsa.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- .gitignore
|
51
|
+
- .ruby-version
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- VERSION
|
57
|
+
- lib/matross.rb
|
58
|
+
- lib/matross/base.rb
|
59
|
+
- lib/matross/foreman.rb
|
60
|
+
- lib/matross/local_assets.rb
|
61
|
+
- lib/matross/nginx.rb
|
62
|
+
- lib/matross/templates/foreman/process.conf.erb
|
63
|
+
- lib/matross/templates/nginx/nginx_virtual_host_conf.erb
|
64
|
+
- lib/matross/templates/unicorn/unicorn.rb.erb
|
65
|
+
- lib/matross/unicorn.rb
|
66
|
+
- lib/matross/version.rb
|
67
|
+
- matross.gemspec
|
68
|
+
homepage: https://github.com/innvent/matross
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.0.7
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Our collection of opnionated Capistrano recipes
|
92
|
+
test_files: []
|