cap_recipes 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/cap_recipes.gemspec +22 -0
- data/config/deploy.rb +29 -0
- data/config/recipes/base.rb +16 -0
- data/config/recipes/check.rb +13 -0
- data/config/recipes/nginx.rb +28 -0
- data/config/recipes/nodejs.rb +9 -0
- data/config/recipes/postgresql.rb +34 -0
- data/config/recipes/rbenv.rb +27 -0
- data/config/recipes/templates/maintenance.html.erb +33 -0
- data/config/recipes/templates/nginx_unicorn.erb +45 -0
- data/config/recipes/templates/postgresql.yml.erb +8 -0
- data/config/recipes/templates/unicorn.rb.erb +34 -0
- data/config/recipes/templates/unicorn_init.erb +84 -0
- data/config/recipes/unicorn.rb +26 -0
- data/lib/cap_recipes.rb +3 -0
- data/lib/generators/cap_recipes/install/install_generator.rb +20 -0
- metadata +120 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Robert Evans
|
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,33 @@
|
|
1
|
+
# CapRecipes
|
2
|
+
|
3
|
+
A set of capistrano deploy scripts that were initially lifted from RailsCasts.
|
4
|
+
Since then, there has been additions.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'cap_recipes'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install cap_recipes
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
There is a Rails generator to add the config files to your application's
|
23
|
+
config directory.
|
24
|
+
|
25
|
+
$ rails generate cap_recipes:install
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/cap_recipes.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "cap_recipes"
|
7
|
+
gem.version = '0.0.3'
|
8
|
+
gem.authors = ["Robert Evans"]
|
9
|
+
gem.email = ["robert@codewranglers.org"]
|
10
|
+
gem.description = %q{A gem of capistrano recipes used in building and deploying a server.}
|
11
|
+
gem.summary = %q{A gem of capistrano recipes used in building and deploying a server}
|
12
|
+
gem.homepage = ""
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_development_dependency 'minitest'
|
20
|
+
gem.add_dependency "railties", ">= 3.1.0", "< 5.0"
|
21
|
+
gem.add_dependency "thor", "~> 0.16"
|
22
|
+
end
|
data/config/deploy.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "bundler/capistrano"
|
2
|
+
|
3
|
+
load "config/recipes/base"
|
4
|
+
load "config/recipes/nginx"
|
5
|
+
load "config/recipes/unicorn"
|
6
|
+
load "config/recipes/postgresql"
|
7
|
+
load "config/recipes/nodejs"
|
8
|
+
load "config/recipes/rbenv"
|
9
|
+
load "config/recipes/check"
|
10
|
+
load "config/recipes/asset_pipeline"
|
11
|
+
|
12
|
+
server "127.0.0.1", :web, :app, :db, primary: true
|
13
|
+
|
14
|
+
set :user, "deployer"
|
15
|
+
set :application, "app"
|
16
|
+
set :deploy_to, "/data/#{application}"
|
17
|
+
set :deploy_via, :remote_cache
|
18
|
+
set :use_sudo, false
|
19
|
+
|
20
|
+
set :scm, "git"
|
21
|
+
set :repository, "git@github.com:yourname/#{application}.git"
|
22
|
+
set :branch, "master"
|
23
|
+
|
24
|
+
set :maintenance_template_path, File.expand_path("../recipes/templates/maintenance.html.erb", __FILE__)
|
25
|
+
|
26
|
+
default_run_options[:pty] = true
|
27
|
+
ssh_options[:forward_agent] = true
|
28
|
+
|
29
|
+
after "deploy", "deploy:cleanup" # keep only the last 5 releases
|
@@ -0,0 +1,16 @@
|
|
1
|
+
def template(from, to)
|
2
|
+
erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
|
3
|
+
put ERB.new(erb).result(binding), to
|
4
|
+
end
|
5
|
+
|
6
|
+
def set_default(name, *args, &block)
|
7
|
+
set(name, *args, &block) unless exists?(name)
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :deploy do
|
11
|
+
desc "Install everything onto the server"
|
12
|
+
task :install do
|
13
|
+
run "#{sudo} apt-get -y update"
|
14
|
+
run "#{sudo} apt-get -y install python-software-properties"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
namespace :check do
|
2
|
+
desc "Make sure local git is in sync with remote."
|
3
|
+
task :revision, roles: :web do
|
4
|
+
unless `git rev-parse HEAD` == `git rev-parse origin/#{branch}`
|
5
|
+
puts "WARNING: HEAD is not the same as origin/#{branch}"
|
6
|
+
puts "Run `git push` to sync changes."
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
end
|
10
|
+
before "deploy", "check:revision"
|
11
|
+
before "deploy:migrations", "check:revision"
|
12
|
+
before "deploy:cold", "check:revision"
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
namespace :nginx do
|
2
|
+
desc "Install latest stable release of nginx"
|
3
|
+
task :install, roles: :web do
|
4
|
+
run "#{sudo} add-apt-repository ppa:nginx/stable"
|
5
|
+
run "#{sudo} apt-get -y update"
|
6
|
+
run "#{sudo} apt-get -y install nginx"
|
7
|
+
end
|
8
|
+
after "deploy:install", "nginx:install"
|
9
|
+
|
10
|
+
desc "Setup nginx configuration for this application"
|
11
|
+
task :setup, roles: :web do
|
12
|
+
template "nginx_unicorn.erb", "/tmp/nginx_conf"
|
13
|
+
run "#{sudo} mv /tmp/nginx_conf /etc/nginx/sites-enabled/#{application}"
|
14
|
+
run "#{sudo} rm -f /etc/nginx/sites-enabled/default"
|
15
|
+
restart
|
16
|
+
end
|
17
|
+
after "deploy:setup", "nginx:setup"
|
18
|
+
|
19
|
+
%w[start stop restart].each do |command|
|
20
|
+
desc "#{command} nginx"
|
21
|
+
task command, roles: :web do
|
22
|
+
run "#{sudo} service nginx #{command}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# NOTE: I found it necessary to manually fix the init script as shown here
|
28
|
+
# https://bugs.launchpad.net/nginx/+bug/1033856
|
@@ -0,0 +1,9 @@
|
|
1
|
+
namespace :nodejs do
|
2
|
+
desc "Install the latest relase of Node.js"
|
3
|
+
task :install, roles: :app do
|
4
|
+
run "#{sudo} add-apt-repository ppa:chris-lea/node.js"
|
5
|
+
run "#{sudo} apt-get -y update"
|
6
|
+
run "#{sudo} apt-get -y install nodejs"
|
7
|
+
end
|
8
|
+
after "deploy:install", "nodejs:install"
|
9
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
set_default(:postgresql_host, "localhost")
|
2
|
+
set_default(:postgresql_user) { application }
|
3
|
+
set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
|
4
|
+
set_default(:postgresql_database) { "#{application}_production" }
|
5
|
+
|
6
|
+
namespace :postgresql do
|
7
|
+
desc "Install the latest stable release of PostgreSQL."
|
8
|
+
task :install, roles: :db, only: {primary: true} do
|
9
|
+
run "#{sudo} add-apt-repository ppa:pitti/postgresql"
|
10
|
+
run "#{sudo} apt-get -y update"
|
11
|
+
run "#{sudo} apt-get -y install postgresql libpq-dev"
|
12
|
+
end
|
13
|
+
after "deploy:install", "postgresql:install"
|
14
|
+
|
15
|
+
desc "Create a database for this application."
|
16
|
+
task :create_database, roles: :db, only: {primary: true} do
|
17
|
+
run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
|
18
|
+
run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
|
19
|
+
end
|
20
|
+
after "deploy:setup", "postgresql:create_database"
|
21
|
+
|
22
|
+
desc "Generate the database.yml configuration file."
|
23
|
+
task :setup, roles: :app do
|
24
|
+
run "mkdir -p #{shared_path}/config"
|
25
|
+
template "postgresql.yml.erb", "#{shared_path}/config/database.yml"
|
26
|
+
end
|
27
|
+
after "deploy:setup", "postgresql:setup"
|
28
|
+
|
29
|
+
desc "Symlink the database.yml file into latest release"
|
30
|
+
task :symlink, roles: :app do
|
31
|
+
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
32
|
+
end
|
33
|
+
after "deploy:finalize_update", "postgresql:symlink"
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
set_default :ruby_version, "1.9.3-p125"
|
2
|
+
set_default :rbenv_bootstrap, "bootstrap-ubuntu-10-04"
|
3
|
+
|
4
|
+
namespace :rbenv do
|
5
|
+
desc "Install rbenv, Ruby, and the Bundler gem"
|
6
|
+
task :install, roles: :app do
|
7
|
+
run "#{sudo} apt-get -y install curl git-core"
|
8
|
+
run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
|
9
|
+
bashrc = <<-BASHRC
|
10
|
+
if [ -d $HOME/.rbenv ]; then
|
11
|
+
export PATH="$HOME/.rbenv/bin:$PATH"
|
12
|
+
eval "$(rbenv init -)"
|
13
|
+
fi
|
14
|
+
BASHRC
|
15
|
+
put bashrc, "/tmp/rbenvrc"
|
16
|
+
run "cat /tmp/rbenvrc ~/.bashrc > ~/.bashrc.tmp"
|
17
|
+
run "mv ~/.bashrc.tmp ~/.bashrc"
|
18
|
+
run %q{export PATH="$HOME/.rbenv/bin:$PATH"}
|
19
|
+
run %q{eval "$(rbenv init -)"}
|
20
|
+
run "rbenv #{rbenv_bootstrap}"
|
21
|
+
run "rbenv install #{ruby_version}"
|
22
|
+
run "rbenv global #{ruby_version}"
|
23
|
+
run "gem install bundler --no-ri --no-rdoc"
|
24
|
+
run "rbenv rehash"
|
25
|
+
end
|
26
|
+
after "deploy:install", "rbenv:install"
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Blog</title>
|
5
|
+
<style type="text/css">
|
6
|
+
html, body {
|
7
|
+
background-color: #4B7399;
|
8
|
+
font-family: Verdana, Helvetica, Arial;
|
9
|
+
font-size: 14px;
|
10
|
+
}
|
11
|
+
|
12
|
+
a {
|
13
|
+
color: #0000FF;
|
14
|
+
img { border: none; }
|
15
|
+
}
|
16
|
+
|
17
|
+
#container {
|
18
|
+
width: 80%;
|
19
|
+
margin: 0 auto;
|
20
|
+
background-color: #FFF;
|
21
|
+
padding: 20px 40px;
|
22
|
+
border: solid 1px black;
|
23
|
+
margin-top: 20px;
|
24
|
+
}
|
25
|
+
</style>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<div id="container">
|
29
|
+
<h1>The system is down for <%= reason ? reason : "maintenance" %></h1>
|
30
|
+
<p>It will be back <%= deadline ? deadline : "soon" %></p>
|
31
|
+
</div>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
upstream unicorn {
|
2
|
+
server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80 default deferred;
|
7
|
+
# server_name example.com;
|
8
|
+
root <%= current_path %>/public;
|
9
|
+
|
10
|
+
if (-f $document_root/system/maintenance.html) {
|
11
|
+
return 503;
|
12
|
+
}
|
13
|
+
error_page 503 @maintenance;
|
14
|
+
location @maintenance {
|
15
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
16
|
+
break;
|
17
|
+
}
|
18
|
+
|
19
|
+
location ^~ /assets/ {
|
20
|
+
gzip_static on;
|
21
|
+
expires max;
|
22
|
+
add_header Cache-Control public;
|
23
|
+
}
|
24
|
+
|
25
|
+
try_files $uri/index.html $uri @unicorn;
|
26
|
+
location @unicorn {
|
27
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
28
|
+
proxy_set_header Host $http_host;
|
29
|
+
proxy_redirect off;
|
30
|
+
proxy_pass http://unicorn;
|
31
|
+
}
|
32
|
+
|
33
|
+
error_page 500 502 503 504 /500.html;
|
34
|
+
client_max_body_size 4G;
|
35
|
+
keepalive_timeout 10;
|
36
|
+
|
37
|
+
if (-f $document_root/system/maintenance.html) {
|
38
|
+
return 503;
|
39
|
+
}
|
40
|
+
error_page 503 @maintenance;
|
41
|
+
location @maintenance {
|
42
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
43
|
+
break;
|
44
|
+
}
|
45
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
working_directory "<%= current_path %>"
|
2
|
+
pid "<%= unicorn_pid %>"
|
3
|
+
stderr_path "<%= unicorn_log %>"
|
4
|
+
stdout_path "<%= unicorn_log %>"
|
5
|
+
|
6
|
+
listen "/tmp/unicorn.<%= application %>.sock"
|
7
|
+
worker_processes <%= unicorn_workers %>
|
8
|
+
timeout 30
|
9
|
+
|
10
|
+
preload_app true
|
11
|
+
|
12
|
+
before_fork do |server, worker|
|
13
|
+
# Disconnect since the database connection will not carry over
|
14
|
+
if defined? ActiveRecord::Base
|
15
|
+
ActiveRecord::Base.connection.disconnect!
|
16
|
+
end
|
17
|
+
|
18
|
+
# Quit the old unicorn process
|
19
|
+
old_pid = "#{server.config[:pid]}.oldbin"
|
20
|
+
if File.exists?(old_pid) && server.pid != old_pid
|
21
|
+
begin
|
22
|
+
Process.kill("QUIT", File.read(old_pid).to_i)
|
23
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
24
|
+
# someone else did our job for us
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
after_fork do |server, worker|
|
30
|
+
# Start up the database connection again in the worker
|
31
|
+
if defined?(ActiveRecord::Base)
|
32
|
+
ActiveRecord::Base.establish_connection
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: unicorn
|
4
|
+
# Required-Start: $remote_fs $syslog
|
5
|
+
# Required-Stop: $remote_fs $syslog
|
6
|
+
# Default-Start: 2 3 4 5
|
7
|
+
# Default-Stop: 0 1 6
|
8
|
+
# Short-Description: Manage unicorn server
|
9
|
+
# Description: Start, stop, restart unicorn server for a specific application.
|
10
|
+
### END INIT INFO
|
11
|
+
set -e
|
12
|
+
|
13
|
+
# Feel free to change any of the following variables for your app:
|
14
|
+
TIMEOUT=${TIMEOUT-60}
|
15
|
+
APP_ROOT=<%= current_path %>
|
16
|
+
PID=<%= unicorn_pid %>
|
17
|
+
CMD="cd <%= current_path %>; bundle exec unicorn -D -c <%= unicorn_config %> -E production"
|
18
|
+
AS_USER=<%= unicorn_user %>
|
19
|
+
set -u
|
20
|
+
|
21
|
+
OLD_PIN="$PID.oldbin"
|
22
|
+
|
23
|
+
sig () {
|
24
|
+
test -s "$PID" && kill -$1 `cat $PID`
|
25
|
+
}
|
26
|
+
|
27
|
+
oldsig () {
|
28
|
+
test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
|
29
|
+
}
|
30
|
+
|
31
|
+
run () {
|
32
|
+
if [ "$(id -un)" = "$AS_USER" ]; then
|
33
|
+
eval $1
|
34
|
+
else
|
35
|
+
su -c "$1" - $AS_USER
|
36
|
+
fi
|
37
|
+
}
|
38
|
+
|
39
|
+
case "$1" in
|
40
|
+
start)
|
41
|
+
sig 0 && echo >&2 "Already running" && exit 0
|
42
|
+
run "$CMD"
|
43
|
+
;;
|
44
|
+
stop)
|
45
|
+
sig QUIT && exit 0
|
46
|
+
echo >&2 "Not running"
|
47
|
+
;;
|
48
|
+
force-stop)
|
49
|
+
sig TERM && exit 0
|
50
|
+
echo >&2 "Not running"
|
51
|
+
;;
|
52
|
+
restart|reload)
|
53
|
+
sig USR2 && echo reloaded OK && exit 0
|
54
|
+
echo >&2 "Couldn't reload, starting '$CMD' instead"
|
55
|
+
run "$CMD"
|
56
|
+
;;
|
57
|
+
upgrade)
|
58
|
+
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
|
59
|
+
then
|
60
|
+
n=$TIMEOUT
|
61
|
+
while test -s $OLD_PIN && test $n -ge 0
|
62
|
+
do
|
63
|
+
printf '.' && sleep 1 && n=$(( $n - 1 ))
|
64
|
+
done
|
65
|
+
echo
|
66
|
+
|
67
|
+
if test $n -lt 0 && test -s $OLD_PIN
|
68
|
+
then
|
69
|
+
echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
|
70
|
+
exit 1
|
71
|
+
fi
|
72
|
+
exit 0
|
73
|
+
fi
|
74
|
+
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
|
75
|
+
run "$CMD"
|
76
|
+
;;
|
77
|
+
reopen-logs)
|
78
|
+
sig USR1
|
79
|
+
;;
|
80
|
+
*)
|
81
|
+
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
|
82
|
+
exit 1
|
83
|
+
;;
|
84
|
+
esac
|
@@ -0,0 +1,26 @@
|
|
1
|
+
set_default(:unicorn_user) { user }
|
2
|
+
set_default(:unicorn_pid) { "#{current_path}/tmp/pids/unicorn.pid" }
|
3
|
+
set_default(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
|
4
|
+
set_default(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
|
5
|
+
set_default(:unicorn_workers, 2)
|
6
|
+
|
7
|
+
namespace :unicorn do
|
8
|
+
desc "Setup Unicorn initializer and app configuration"
|
9
|
+
task :setup, roles: :app do
|
10
|
+
run "mkdir -p #{shared_path}/config"
|
11
|
+
template "unicorn.rb.erb", unicorn_config
|
12
|
+
template "unicorn_init.erb", "/tmp/unicorn_init"
|
13
|
+
run "chmod +x /tmp/unicorn_init"
|
14
|
+
run "#{sudo} mv /tmp/unicorn_init /etc/init.d/unicorn_#{application}"
|
15
|
+
run "#{sudo} update-rc.d -f unicorn_#{application} defaults"
|
16
|
+
end
|
17
|
+
after "deploy:setup", "unicorn:setup"
|
18
|
+
|
19
|
+
%w[start stop restart].each do |command|
|
20
|
+
desc "#{command} unicorn"
|
21
|
+
task command, roles: :app do
|
22
|
+
run "service unicorn_#{application} #{command}"
|
23
|
+
end
|
24
|
+
after "deploy:#{command}", "unicorn:#{command}"
|
25
|
+
end
|
26
|
+
end
|
data/lib/cap_recipes.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
|
4
|
+
module CapRecipes
|
5
|
+
module Generators
|
6
|
+
class InstallGenerator < ::Rails::Generators::Base
|
7
|
+
desc "This generator installs the capistrano recipes to the config/recipes directory"
|
8
|
+
source_root File.expand_path('../../../../../config', __FILE__)
|
9
|
+
|
10
|
+
def copy_recipes
|
11
|
+
say_status("copying", "Capistrano Recipes to config/recipes", :green)
|
12
|
+
directory("recipes", "config/recipes")
|
13
|
+
|
14
|
+
say_status("copying", "A default capistrano deploy script to config/deply.rb", :green)
|
15
|
+
copy_file("deploy.rb", "config/deploy.rb")
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cap_recipes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Robert Evans
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: minitest
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: railties
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.1.0
|
38
|
+
- - <
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 3.1.0
|
49
|
+
- - <
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '5.0'
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: thor
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.16'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.16'
|
68
|
+
description: A gem of capistrano recipes used in building and deploying a server.
|
69
|
+
email:
|
70
|
+
- robert@codewranglers.org
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- .gitignore
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- cap_recipes.gemspec
|
81
|
+
- config/deploy.rb
|
82
|
+
- config/recipes/base.rb
|
83
|
+
- config/recipes/check.rb
|
84
|
+
- config/recipes/nginx.rb
|
85
|
+
- config/recipes/nodejs.rb
|
86
|
+
- config/recipes/postgresql.rb
|
87
|
+
- config/recipes/rbenv.rb
|
88
|
+
- config/recipes/templates/maintenance.html.erb
|
89
|
+
- config/recipes/templates/nginx_unicorn.erb
|
90
|
+
- config/recipes/templates/postgresql.yml.erb
|
91
|
+
- config/recipes/templates/unicorn.rb.erb
|
92
|
+
- config/recipes/templates/unicorn_init.erb
|
93
|
+
- config/recipes/unicorn.rb
|
94
|
+
- lib/cap_recipes.rb
|
95
|
+
- lib/generators/cap_recipes/install/install_generator.rb
|
96
|
+
homepage: ''
|
97
|
+
licenses: []
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 1.8.23
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: A gem of capistrano recipes used in building and deploying a server
|
120
|
+
test_files: []
|