capones_recipes 0.4.3 → 0.5.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/VERSION +1 -1
- data/capones_recipes.gemspec +1 -1
- data/lib/recipes/database/sync.rb +20 -8
- data/lib/recipes/settings_logic/settings_logic.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/capones_recipes.gemspec
CHANGED
@@ -46,13 +46,13 @@ Capistrano::Configuration.instance.load do
|
|
46
46
|
DESC
|
47
47
|
task :db, :roles => :db, :only => { :primary => true } do
|
48
48
|
# Use production on non-multistage
|
49
|
-
stage
|
49
|
+
set :stage, 'production' unless exists?(:stage)
|
50
50
|
|
51
51
|
filename = "database.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
52
52
|
on_rollback { delete "#{shared_path}/sync/#{filename}" }
|
53
53
|
|
54
54
|
# Remote DB dump
|
55
|
-
username, password, database, host =
|
55
|
+
username, password, database, host = remote_database_config(stage)
|
56
56
|
host_option = host ? "--host='#{host}'" : ""
|
57
57
|
run "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{shared_path}/sync/#{filename}" do |channel, stream, data|
|
58
58
|
puts data
|
@@ -76,7 +76,7 @@ Capistrano::Configuration.instance.load do
|
|
76
76
|
DESC
|
77
77
|
task :fs, :roles => :web, :once => true do
|
78
78
|
# Use production on non-multistage
|
79
|
-
stage
|
79
|
+
set :stage, 'production' unless exists?(:stage)
|
80
80
|
|
81
81
|
server, port = host_and_port
|
82
82
|
|
@@ -114,7 +114,7 @@ Capistrano::Configuration.instance.load do
|
|
114
114
|
DESC
|
115
115
|
task :db, :roles => :db, :only => { :primary => true } do
|
116
116
|
# Use production on non-multistage
|
117
|
-
stage
|
117
|
+
set :stage, 'production' unless exists?(:stage)
|
118
118
|
|
119
119
|
filename = "database.#{stage}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.sql.bz2"
|
120
120
|
|
@@ -124,7 +124,7 @@ Capistrano::Configuration.instance.load do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
# Make a backup before importing
|
127
|
-
username, password, database, host =
|
127
|
+
username, password, database, host = remote_database_config(stage)
|
128
128
|
host_option = host ? "--host='#{host}'" : ""
|
129
129
|
run "mysqldump -u #{username} --password='#{password}' #{host_option} #{database} | bzip2 -9 > #{shared_path}/sync/#{filename}" do |channel, stream, data|
|
130
130
|
puts data
|
@@ -139,7 +139,7 @@ Capistrano::Configuration.instance.load do
|
|
139
139
|
system "rm -f #{filename}"
|
140
140
|
|
141
141
|
# Remote DB import
|
142
|
-
username, password, database, host =
|
142
|
+
username, password, database, host = remote_database_config(stage)
|
143
143
|
host_option = host ? "--host='#{host}'" : ""
|
144
144
|
run "bzip2 -d -c #{shared_path}/sync/#{filename} | mysql -u #{username} --password='#{password}' #{host_option} #{database}; rm -f #{shared_path}/sync/#{filename}"
|
145
145
|
purge_old_backups "database"
|
@@ -154,7 +154,7 @@ Capistrano::Configuration.instance.load do
|
|
154
154
|
DESC
|
155
155
|
task :fs, :roles => :web, :once => true do
|
156
156
|
# Use production on non-multistage
|
157
|
-
stage
|
157
|
+
set :stage, 'production' unless exists?(:stage)
|
158
158
|
|
159
159
|
server, port = host_and_port
|
160
160
|
Array(fetch(:sync_directories, [])).each do |syncdir|
|
@@ -188,6 +188,18 @@ Capistrano::Configuration.instance.load do
|
|
188
188
|
return database["#{db}"]['username'], database["#{db}"]['password'], database["#{db}"]['database'], database["#{db}"]['host']
|
189
189
|
end
|
190
190
|
|
191
|
+
#
|
192
|
+
# Reads the database credentials from the remote config/database.yml file
|
193
|
+
# +db+ the name of the environment to get the credentials for
|
194
|
+
# Returns username, password, database
|
195
|
+
#
|
196
|
+
def remote_database_config(db)
|
197
|
+
env = rails_env || db
|
198
|
+
config = capture "cat #{deploy_to}/current/config/database.yml"
|
199
|
+
database = YAML::load(config)
|
200
|
+
return database["#{env}"]['username'], database["#{env}"]['password'], database["#{env}"]['database'], database["#{env}"]['host']
|
201
|
+
end
|
202
|
+
|
191
203
|
#
|
192
204
|
# Returns the actual host name to sync and port
|
193
205
|
#
|
@@ -211,4 +223,4 @@ Capistrano::Configuration.instance.load do
|
|
211
223
|
end
|
212
224
|
|
213
225
|
end
|
214
|
-
end
|
226
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Capistrano::Configuration.instance.load do
|
2
2
|
before "deploy:setup", :settings_logic
|
3
|
-
|
3
|
+
before "bundler:update", "settings_logic:symlink"
|
4
4
|
|
5
5
|
namespace :settings_logic do
|
6
6
|
desc "Create application yaml in capistrano shared path"
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: capones_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.5.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Roman Simecek
|
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
162
|
requirements:
|
163
163
|
- - ">="
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
hash:
|
165
|
+
hash: -2613591455120783238
|
166
166
|
segments:
|
167
167
|
- 0
|
168
168
|
version: "0"
|