ricodigo-capistrano-recipes 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/ricodigo-install-server +15 -15
- data/generators/unicorn.rb.erb +1 -2
- data/lib/recipes/push_deploy.rb +45 -0
- data/ricodigo-capistrano-recipes.gemspec +3 -2
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/bin/ricodigo-install-server
CHANGED
@@ -21,7 +21,7 @@ def setup_repos(ssh)
|
|
21
21
|
ssh.exec! 'sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10' do |c,s,d|
|
22
22
|
puts d
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
ssh.exec! "sudo apt-get update" do |c,s,d|
|
26
26
|
puts d
|
27
27
|
end
|
@@ -30,8 +30,8 @@ end
|
|
30
30
|
def install_packages(ssh)
|
31
31
|
puts ">> Installing packages..."
|
32
32
|
packages = %w[
|
33
|
-
bind9 build-essential ufw libreadline6-dev git-core
|
34
|
-
libxslt1-dev libxml2-dev libssl-dev nginx mongodb-10gen curl
|
33
|
+
bind9 build-essential ufw libreadline6-dev git-core
|
34
|
+
libxslt1-dev libxml2-dev libssl-dev nginx mongodb-10gen curl
|
35
35
|
libcurl4-openssl-dev graphicsmagick openjdk-6-jre-headless libsasl2-dev
|
36
36
|
]
|
37
37
|
|
@@ -71,7 +71,7 @@ end
|
|
71
71
|
|
72
72
|
def setup_firewall(ssh)
|
73
73
|
puts ">> Setup firewall..."
|
74
|
-
|
74
|
+
|
75
75
|
ssh.exec! "sudo ufw disable" do |channel, stream, data|
|
76
76
|
puts data
|
77
77
|
end
|
@@ -84,9 +84,9 @@ def setup_firewall(ssh)
|
|
84
84
|
commands << "sudo ufw allow to any port 25"
|
85
85
|
commands << "sudo ufw allow to any port 587"
|
86
86
|
commands << "sudo ufw default deny"
|
87
|
-
|
87
|
+
|
88
88
|
ssh.exec!(commands.join(" && ")) {|c,s,d| puts d }
|
89
|
-
ssh.exec!("sudo ufw enable") {|c,s,d| puts d }
|
89
|
+
ssh.exec!("sudo ufw enable") {|c,s,d| puts d; d.send_data("yes") }
|
90
90
|
|
91
91
|
ssh.exec! "iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT"
|
92
92
|
ssh.exec! "iptables -A INPUT -i lo -j ACCEPT"
|
@@ -116,17 +116,17 @@ end
|
|
116
116
|
|
117
117
|
def install_gems(ssh)
|
118
118
|
puts ">> Installing required gems..."
|
119
|
-
|
119
|
+
|
120
120
|
command = %@
|
121
121
|
echo "gem: --no-ri --no-rdoc" >> /etc/gemrc
|
122
122
|
echo "update: --no-ri --no-rdoc" >> /etc/gemrc
|
123
123
|
echo "install: --no-ri --no-rdoc" >> /etc/gemrc
|
124
124
|
@
|
125
125
|
ssh.exec!("sudo bash -c '#{command}'") {|c,s,d| puts d }
|
126
|
-
|
126
|
+
|
127
127
|
gems = %w[
|
128
|
-
rails mongoid whenever capistrano unicorn mongoid_ext magent
|
129
|
-
bson_ext sanitize uuidtools ruby-stemmer mini_magick magic
|
128
|
+
rails mongoid whenever capistrano unicorn mongoid_ext magent
|
129
|
+
bson_ext sanitize uuidtools ruby-stemmer mini_magick magic
|
130
130
|
haml sass compass mechanize nokogiri rdiscount
|
131
131
|
]
|
132
132
|
|
@@ -136,10 +136,10 @@ echo "install: --no-ri --no-rdoc" >> /etc/gemrc
|
|
136
136
|
end
|
137
137
|
|
138
138
|
Net::SSH.start(host, user) do |ssh|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
139
|
+
setup_repos(ssh)
|
140
|
+
install_packages(ssh)
|
141
|
+
install_postfix(ssh)
|
142
|
+
setup_firewall(ssh) unless host =~ /amazonaws\.com$/
|
143
|
+
install_rvm(ssh)
|
144
144
|
install_gems(ssh)
|
145
145
|
end
|
data/generators/unicorn.rb.erb
CHANGED
@@ -29,9 +29,8 @@ before_fork do |server, worker|
|
|
29
29
|
if File.exists?(old_pid) && server.pid != old_pid
|
30
30
|
pid = File.read(old_pid).to_i
|
31
31
|
begin
|
32
|
+
puts ">> Killing old unicorn process"
|
32
33
|
Process.kill("QUIT", pid)
|
33
|
-
Process.kill(0, pid)
|
34
|
-
Process.wait
|
35
34
|
rescue Errno::ECHILD, Errno::ESRCH => e
|
36
35
|
$stderr.puts ">> Process #{pid} has stopped"
|
37
36
|
rescue Errno::ENOENT => e
|
@@ -0,0 +1,45 @@
|
|
1
|
+
Capistrano::Configuration.instance.load do
|
2
|
+
namespace :push_deploy do
|
3
|
+
set(:push_deploy_repo) { "/home/#{user}/code/#{application}"}
|
4
|
+
desc "setup everything to deploy via push"
|
5
|
+
task :setup, :roles => :app do
|
6
|
+
server = roles[:app].servers.first
|
7
|
+
|
8
|
+
run "rm -rf #{push_deploy_repo}"
|
9
|
+
run "mkdir -p ~/code"
|
10
|
+
run "git clone --depth=1 #{repository} #{push_deploy_repo}"
|
11
|
+
run "cd #{push_deploy_repo} && git config receive.denyCurrentBranch ignore"
|
12
|
+
|
13
|
+
hook = %@#!/bin/bash
|
14
|
+
cd ..
|
15
|
+
GIT_DIR=$(pwd)/.git
|
16
|
+
git reset --hard master
|
17
|
+
git update-server-info
|
18
|
+
unset GIT_DIR
|
19
|
+
|
20
|
+
bundle install
|
21
|
+
cap #{environment} deploy
|
22
|
+
@
|
23
|
+
hook_path = "#{push_deploy_repo}/.git/hooks/post-receive"
|
24
|
+
put hook, hook_path
|
25
|
+
run "chmod 755 #{hook_path}"
|
26
|
+
|
27
|
+
puts %@
|
28
|
+
|
29
|
+
== Instructions
|
30
|
+
|
31
|
+
add deploy repository to your remotes
|
32
|
+
|
33
|
+
git remote add deploy #{user}\@#{server}:#{push_deploy_repo}
|
34
|
+
|
35
|
+
add this to your deploy.rb
|
36
|
+
|
37
|
+
set :repository, "#{user}\@#{server}:#{push_deploy_repo}"
|
38
|
+
|
39
|
+
to deploy a branch just type:
|
40
|
+
|
41
|
+
git push deploy your_branch:master -f
|
42
|
+
@
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ricodigo-capistrano-recipes}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David A. Cuadrado"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-28}
|
13
13
|
s.default_executable = %q{ricodigo-install-server}
|
14
14
|
s.description = %q{our capistrano recipes. forked from capistrano-recipes}
|
15
15
|
s.email = %q{krawek@gmail.com}
|
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
"lib/recipes/log.rb",
|
44
44
|
"lib/recipes/magent.rb",
|
45
45
|
"lib/recipes/nginx.rb",
|
46
|
+
"lib/recipes/push_deploy.rb",
|
46
47
|
"lib/recipes/symlinks.rb",
|
47
48
|
"lib/recipes/unicorn.rb",
|
48
49
|
"lib/ricodigo_capistrano_recipes.rb",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 6
|
9
|
+
version: 0.1.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David A. Cuadrado
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-05-
|
17
|
+
date: 2011-05-28 00:00:00 -05:00
|
18
18
|
default_executable: ricodigo-install-server
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/recipes/log.rb
|
190
190
|
- lib/recipes/magent.rb
|
191
191
|
- lib/recipes/nginx.rb
|
192
|
+
- lib/recipes/push_deploy.rb
|
192
193
|
- lib/recipes/symlinks.rb
|
193
194
|
- lib/recipes/unicorn.rb
|
194
195
|
- lib/ricodigo_capistrano_recipes.rb
|
@@ -207,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
208
|
requirements:
|
208
209
|
- - ">="
|
209
210
|
- !ruby/object:Gem::Version
|
210
|
-
hash:
|
211
|
+
hash: 2802268916006337518
|
211
212
|
segments:
|
212
213
|
- 0
|
213
214
|
version: "0"
|