youthtree-capistrano 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/lib/youth_tree/capistrano.rb +1 -1
- data/lib/youth_tree/recipes/base.rb +5 -0
- data/lib/youth_tree/recipes/syncing.rb +25 -40
- data/youthtree-capistrano.gemspec +5 -2
- metadata +18 -4
data/Rakefile
CHANGED
@@ -21,6 +21,11 @@ YouthTree::Capistrano.load do
|
|
21
21
|
run "rm -rf '#{to}' && ln -s '#{from}' '#{to}'"
|
22
22
|
end
|
23
23
|
|
24
|
+
def lrun(command)
|
25
|
+
puts ">> #{command} # Run locally"
|
26
|
+
system command
|
27
|
+
end
|
28
|
+
|
24
29
|
%w(staging production).each do |env_name|
|
25
30
|
task env_name.to_sym do
|
26
31
|
puts "** Switching stage to #{env_name} **"
|
@@ -1,48 +1,25 @@
|
|
1
1
|
require 'ostruct'
|
2
2
|
YouthTree::Capistrano.load_named(:syncing) do
|
3
3
|
|
4
|
-
yt_cset(:syncing_version_name)
|
5
|
-
yt_cset(:syncing_remote_dir)
|
6
|
-
yt_cset(:
|
7
|
-
yt_cset(:
|
4
|
+
yt_cset(:syncing_version_name) { "#{application}-#{stage}-#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}" }
|
5
|
+
yt_cset(:syncing_remote_dir) { "#{shared_path}/sync" }
|
6
|
+
yt_cset(:syncing_current_remote_dir) { "#{syncing_remote_dir}/#{syncing_version_name}" }
|
7
|
+
yt_cset(:syncing_current_local_dir) { "/tmp/#{syncing_version_name}" }
|
8
|
+
yt_cset(:syncing_local_archive) { "#{syncing_current_local_dir}.tar.gz"}
|
9
|
+
yt_cset(:syncing_remote_archive) { "#{syncing_current_remote_dir}.tar.gz"}
|
8
10
|
|
9
11
|
yt_cset :syncing_remote_blacklist, ["production"]
|
10
12
|
|
11
13
|
namespace :sync do
|
12
14
|
|
13
|
-
def config_from(text, env = ENV['RAILS_ENV'])
|
14
|
-
full_config = YAML.load(text) || {}
|
15
|
-
config = full_config[env || "development"] || {}
|
16
|
-
OpenStruct.new(config)
|
17
|
-
end
|
18
|
-
|
19
|
-
def remote_db_config
|
20
|
-
config_from capture("cat '#{shared_path}/#{database_shared_config}'"), rails_env
|
21
|
-
end
|
22
|
-
|
23
|
-
def local_db_config
|
24
|
-
config_from File.read("config/database.yml")
|
25
|
-
end
|
26
|
-
|
27
|
-
def options_for_config(config)
|
28
|
-
host_command = config.host.nil? ? '' : "-h #{config.host}"
|
29
|
-
"-u #{config.username} --password='#{config.password}' #{host_command} #{config.database}"
|
30
|
-
end
|
31
|
-
|
32
|
-
def dump_command_for(config)
|
33
|
-
"mysqldump #{options_for_config(config)}"
|
34
|
-
end
|
35
|
-
|
36
|
-
def load_command_for(config)
|
37
|
-
"mysql #{options_for_config(config)}"
|
38
|
-
end
|
39
|
-
|
40
15
|
task :cleanup_remote do
|
16
|
+
run "rm -rf #{syncing_current_remote_dir}"
|
41
17
|
run "rm -rf #{syncing_remote_archive}"
|
42
18
|
end
|
43
19
|
|
44
20
|
task :cleanup_local do
|
45
|
-
|
21
|
+
lrun "rm -rf #{syncing_current_local_dir}"
|
22
|
+
lrun "rm -rf #{syncing_local_archive}"
|
46
23
|
end
|
47
24
|
|
48
25
|
task :prepare do
|
@@ -50,23 +27,31 @@ YouthTree::Capistrano.load_named(:syncing) do
|
|
50
27
|
end
|
51
28
|
|
52
29
|
desc "Dumps the remote db to a file"
|
53
|
-
task :
|
54
|
-
run "#{
|
30
|
+
task :dump_remote_db do
|
31
|
+
run "rm -rf '#{syncing_current_remote_dir}' '#{syncing_remote_archive}'"
|
32
|
+
bundle_exec "ydd dump '#{syncing_current_remote_dir}' '#{latest_release}' --env='#{rails_env}'"
|
33
|
+
run "cd '#{syncing_current_remote_dir}' && tar czf '#{syncing_remote_archive}' ."
|
55
34
|
end
|
56
35
|
|
57
36
|
desc "Loads data into the remote db from the given file"
|
58
37
|
task :load_remote_db do
|
59
|
-
run "
|
38
|
+
run "mkdir -p '#{syncing_current_remote_dir}'"
|
39
|
+
run "cd '#{syncing_current_remote_dir}' && tar xzf '#{syncing_remote_archive}' ."
|
40
|
+
bundle_exec "ydd load '#{syncing_current_remote_dir}' '#{latest_release}' --env='#{rails_env}'"
|
60
41
|
end
|
61
42
|
|
62
43
|
desc "Dumps the local db to a file"
|
63
|
-
task :
|
64
|
-
|
44
|
+
task :dump_local_db do
|
45
|
+
lrun "rm -rf '#{syncing_current_local_dir}' '#{syncing_local_archive}'"
|
46
|
+
lrun "ydd dump '#{syncing_current_local_dir}' '#{Dir.pwd}'"
|
47
|
+
lrun "cd '#{syncing_current_local_dir}' && tar czf '#{syncing_local_archive}' ."
|
65
48
|
end
|
66
49
|
|
67
50
|
desc "Loads data into the local db from the given file"
|
68
51
|
task :load_local_db do
|
69
|
-
|
52
|
+
lrun "mkdir -p '#{syncing_current_local_dir}'"
|
53
|
+
lrun "cd '#{syncing_current_local_dir}' && tar xzf '#{syncing_local_archive}' ."
|
54
|
+
lrun "ydd load '#{syncing_current_local_dir}' '#{Dir.pwd}'"
|
70
55
|
end
|
71
56
|
|
72
57
|
task :download_remote_db do
|
@@ -80,7 +65,7 @@ YouthTree::Capistrano.load_named(:syncing) do
|
|
80
65
|
desc "Downloads the database into the current environment from the remote server"
|
81
66
|
task :down do
|
82
67
|
prepare
|
83
|
-
|
68
|
+
dump_remote_db
|
84
69
|
download_remote_db
|
85
70
|
cleanup_remote
|
86
71
|
load_local_db
|
@@ -93,7 +78,7 @@ YouthTree::Capistrano.load_named(:syncing) do
|
|
93
78
|
exit 1
|
94
79
|
end
|
95
80
|
prepare
|
96
|
-
|
81
|
+
dump_local_db
|
97
82
|
upload_local_db
|
98
83
|
cleanup_local
|
99
84
|
load_remote_db
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{youthtree-capistrano}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Darcy Laycock"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-18}
|
13
13
|
s.description = %q{Capistrano tasks used for common Youth Tree deployments.}
|
14
14
|
s.email = %q{sutto@sutto.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -49,15 +49,18 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.add_runtime_dependency(%q<rvm>, ["~> 1.0"])
|
50
50
|
s.add_runtime_dependency(%q<bundler>, ["~> 1.0"])
|
51
51
|
s.add_runtime_dependency(%q<capistrano>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<ydd>, [">= 0"])
|
52
53
|
else
|
53
54
|
s.add_dependency(%q<rvm>, ["~> 1.0"])
|
54
55
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
55
56
|
s.add_dependency(%q<capistrano>, [">= 0"])
|
57
|
+
s.add_dependency(%q<ydd>, [">= 0"])
|
56
58
|
end
|
57
59
|
else
|
58
60
|
s.add_dependency(%q<rvm>, ["~> 1.0"])
|
59
61
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
60
62
|
s.add_dependency(%q<capistrano>, [">= 0"])
|
63
|
+
s.add_dependency(%q<ydd>, [">= 0"])
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youthtree-capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Darcy Laycock
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-18 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -62,6 +62,20 @@ dependencies:
|
|
62
62
|
version: "0"
|
63
63
|
type: :runtime
|
64
64
|
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: ydd
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
type: :runtime
|
78
|
+
version_requirements: *id004
|
65
79
|
description: Capistrano tasks used for common Youth Tree deployments.
|
66
80
|
email: sutto@sutto.net
|
67
81
|
executables: []
|