recap 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 +4 -0
- data/LICENSE +19 -0
- data/README.md +5 -0
- data/Rakefile +12 -0
- data/bin/tomafro-deploy +3 -0
- data/doc/index.html +216 -0
- data/doc/lib/recap/bundler.html +151 -0
- data/doc/lib/recap/capistrano_extensions.html +203 -0
- data/doc/lib/recap/cli.html +39 -0
- data/doc/lib/recap/compatibility.html +70 -0
- data/doc/lib/recap/deploy.html +373 -0
- data/doc/lib/recap/env.html +103 -0
- data/doc/lib/recap/foreman.html +39 -0
- data/doc/lib/recap/preflight.html +158 -0
- data/doc/lib/recap/rails.html +39 -0
- data/doc/lib/recap/version.html +39 -0
- data/index.rb +53 -0
- data/lib/recap/bundler.rb +45 -0
- data/lib/recap/capistrano_extensions.rb +72 -0
- data/lib/recap/cli.rb +32 -0
- data/lib/recap/compatibility.rb +14 -0
- data/lib/recap/deploy/templates/Capfile.erb +6 -0
- data/lib/recap/deploy.rb +133 -0
- data/lib/recap/env.rb +54 -0
- data/lib/recap/foreman.rb +45 -0
- data/lib/recap/preflight.rb +68 -0
- data/lib/recap/rails.rb +22 -0
- data/lib/recap/version.rb +3 -0
- data/recap.gemspec +25 -0
- metadata +126 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :foreman do
|
3
|
+
set(:procfile) {"#{deploy_to}/Procfile"}
|
4
|
+
set(:foreman_export_format, "upstart")
|
5
|
+
set(:foreman_export_location, "/etc/init")
|
6
|
+
|
7
|
+
namespace :export do
|
8
|
+
task :if_changed do
|
9
|
+
if deployed_file_changed?(procfile)
|
10
|
+
top.foreman.export.default
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default, :roles => :app do
|
15
|
+
if deployed_file_exists?(procfile)
|
16
|
+
tmp = "#{deploy_to}/tmp/foreman"
|
17
|
+
as_app "./bin/foreman export #{foreman_export_format} #{tmp} --procfile #{procfile} --app #{application} --user #{application_user} --log #{deploy_to}/log"
|
18
|
+
sudo "rm -f #{foreman_export_location}/#{application}*"
|
19
|
+
sudo "cp #{tmp}/* #{foreman_export_location}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :start, :roles => :app do
|
25
|
+
if deployed_file_exists?(procfile)
|
26
|
+
sudo "start #{application}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
task :restart, :roles => :app do
|
31
|
+
if deployed_file_exists?(procfile)
|
32
|
+
sudo "restart #{application} || sudo start #{application}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
task :stop, :roles => :app do
|
37
|
+
if deployed_file_exists?(procfile)
|
38
|
+
sudo "stop #{application}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
after 'deploy:update_code', 'foreman:export:if_changed'
|
43
|
+
after 'deploy:restart', 'foreman:restart'
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Before `recap` will work correctly, a small amount of setup work needs to be performed on
|
2
|
+
# all target servers.
|
3
|
+
#
|
4
|
+
# First, each user who can deploy the app needs to have an account on each server, and must be able
|
5
|
+
# to ssh into the box. They'll also each need to be sudoers.
|
6
|
+
#
|
7
|
+
# Secondly, each deploying user should set their git `user.name` and `user.email`. This can easily
|
8
|
+
# be done by running:
|
9
|
+
#
|
10
|
+
# `git config --global user.email "you@example.com"`
|
11
|
+
# `git config --global user.name "Your Name"`
|
12
|
+
#
|
13
|
+
# Finally, a user and group representing the application (and usually with the same name) should be
|
14
|
+
# created. Where possible, the application user will run application code, while the group will own
|
15
|
+
# application specific files. Each deploying user should be added to the application group.
|
16
|
+
#
|
17
|
+
# This preflight recipe checks each of these things in turn, and attempts to give helpful advice
|
18
|
+
# should a check fail.
|
19
|
+
|
20
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
21
|
+
# The preflight check is pretty quick, so run it before every `deploy:setup` and `deploy`
|
22
|
+
before 'deploy:setup', 'preflight:check'
|
23
|
+
before 'deploy', 'preflight:check'
|
24
|
+
|
25
|
+
set(:remote_username) { capture('whoami').strip }
|
26
|
+
|
27
|
+
namespace :preflight do
|
28
|
+
task :check do
|
29
|
+
# First check the `application_user` exists
|
30
|
+
if capture("id #{application_user} > /dev/null 2>&1; echo $?").strip != "0"
|
31
|
+
abort %{
|
32
|
+
The application user '#{application_user}' doesn't exist. You can create this user by logging into the server and running:
|
33
|
+
|
34
|
+
sudo useradd #{application_user}
|
35
|
+
\n}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Then the `application_group`
|
39
|
+
if capture("id -g #{application_group} > /dev/null 2>&1; echo $?").strip != "0"
|
40
|
+
abort %{
|
41
|
+
The application group '#{application_group}' doesn't exist. You can create this group by logging into the server and running:
|
42
|
+
|
43
|
+
sudo groupadd #{application_group}
|
44
|
+
sudo usermod --append -G #{application_group} #{application_user}
|
45
|
+
\n}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Check the git configuration exists
|
49
|
+
if capture('git config user.name || true').strip.empty? || capture('git config user.email || true').strip.empty?
|
50
|
+
abort %{
|
51
|
+
Your remote user must have a git user.name and user.email set. You can set these by logging into the server as #{remote_username} and running:
|
52
|
+
|
53
|
+
git config --global user.email "you@example.com"
|
54
|
+
git config --global user.name "Your Name"
|
55
|
+
\n}
|
56
|
+
end
|
57
|
+
|
58
|
+
# And finally check the remote user is a member of the `application_group`
|
59
|
+
unless capture('groups').split(" ").include?(application_group)
|
60
|
+
abort %{
|
61
|
+
Your remote user must be a member of the '#{application_group}' group in order to perform deployments. You can add yourself to this group by logging into the server and running:
|
62
|
+
|
63
|
+
sudo usermod --append -G #{application_group} #{remote_username}
|
64
|
+
\n}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/recap/rails.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'recap/deploy'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
4
|
+
namespace :rails do
|
5
|
+
namespace :db do
|
6
|
+
task :load_schema do
|
7
|
+
if deployed_file_exists?("db/schema.rb")
|
8
|
+
as_app './bin/rake db:create db:schema:load'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
task :migrate do
|
13
|
+
if deployed_file_changed?("db/schema.rb")
|
14
|
+
as_app './bin/rake db:migrate'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
after "deploy:clone_code", "rails:db:load_schema"
|
21
|
+
after "deploy:update_code", "rails:db:migrate"
|
22
|
+
end
|
data/recap.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "recap/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "recap"
|
7
|
+
s.version = Recap::VERSION
|
8
|
+
s.authors = ["Tom Ward"]
|
9
|
+
s.email = ["tom@popdog.net"]
|
10
|
+
s.homepage = "https://github.com/freerange/recap"
|
11
|
+
s.summary = %q{GIT based deployment recipes for Capistrano}
|
12
|
+
s.description = %q{GIT based deployment recipes for Capistrano}
|
13
|
+
|
14
|
+
s.rubyforge_project = "recap"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency('capistrano', '~>2.6.0')
|
22
|
+
s.add_dependency('thor')
|
23
|
+
s.add_development_dependency('rake', '~>0.9.2')
|
24
|
+
s.add_development_dependency('rocco', '~>0.8.1')
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: recap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tom Ward
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: &70207555688740 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.6.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70207555688740
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thor
|
27
|
+
requirement: &70207555688320 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70207555688320
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70207555687780 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.9.2
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70207555687780
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rocco
|
49
|
+
requirement: &70207555687280 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.1
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70207555687280
|
58
|
+
description: GIT based deployment recipes for Capistrano
|
59
|
+
email:
|
60
|
+
- tom@popdog.net
|
61
|
+
executables:
|
62
|
+
- tomafro-deploy
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/tomafro-deploy
|
72
|
+
- doc/index.html
|
73
|
+
- doc/lib/recap/bundler.html
|
74
|
+
- doc/lib/recap/capistrano_extensions.html
|
75
|
+
- doc/lib/recap/cli.html
|
76
|
+
- doc/lib/recap/compatibility.html
|
77
|
+
- doc/lib/recap/deploy.html
|
78
|
+
- doc/lib/recap/env.html
|
79
|
+
- doc/lib/recap/foreman.html
|
80
|
+
- doc/lib/recap/preflight.html
|
81
|
+
- doc/lib/recap/rails.html
|
82
|
+
- doc/lib/recap/version.html
|
83
|
+
- index.rb
|
84
|
+
- lib/recap/bundler.rb
|
85
|
+
- lib/recap/capistrano_extensions.rb
|
86
|
+
- lib/recap/cli.rb
|
87
|
+
- lib/recap/compatibility.rb
|
88
|
+
- lib/recap/deploy.rb
|
89
|
+
- lib/recap/deploy/templates/Capfile.erb
|
90
|
+
- lib/recap/env.rb
|
91
|
+
- lib/recap/foreman.rb
|
92
|
+
- lib/recap/preflight.rb
|
93
|
+
- lib/recap/rails.rb
|
94
|
+
- lib/recap/version.rb
|
95
|
+
- recap.gemspec
|
96
|
+
homepage: https://github.com/freerange/recap
|
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
|
+
segments:
|
109
|
+
- 0
|
110
|
+
hash: -3210950917994093421
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
segments:
|
118
|
+
- 0
|
119
|
+
hash: -3210950917994093421
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project: recap
|
122
|
+
rubygems_version: 1.8.7
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: GIT based deployment recipes for Capistrano
|
126
|
+
test_files: []
|