sumodev_deploy 0.2.1 → 0.2.2
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/lib/sumodev_deploy.rb +53 -27
- data/sumodev_deploy.gemspec +1 -1
- metadata +1 -1
data/lib/sumodev_deploy.rb
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
|
|
2
2
|
|
|
3
3
|
configuration.load do
|
|
4
|
-
def
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
def _cset(name, *args, &block)
|
|
5
|
+
unless exists?(name)
|
|
6
|
+
set(name, *args, &block)
|
|
7
|
+
end
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
end
|
|
10
|
+
_cset(:client) { abort "sumodev_deploy requires that you set client and project names in your capfile" }
|
|
11
|
+
_cset(:project) { abort "sumodev_deploy requires that you set client and project names in your capfile"}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
self[:project] || stop("sumodev_deploy requires that you set client and project names in your capfile")
|
|
15
|
-
end
|
|
13
|
+
_cset(:db_name) { "#{client[0,8]}_#{project[0,7]}"}
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
_cset(:staging_server, 'dev.sumocoders.be')
|
|
16
|
+
_cset(:production_server, nil)
|
|
17
|
+
_cset(:app_servers) { production_server || staging_server }
|
|
18
|
+
_cset(:web_servers) { production_server || staging_server }
|
|
19
|
+
_cset(:db_server) { production_server || staging_server }
|
|
20
|
+
|
|
21
|
+
_cset(:user, 'sites')
|
|
22
|
+
_cset(:homedir) { "/home/#{user}/" }
|
|
23
|
+
_cset(:app_path) { "apps/#{client}/#{project}" }
|
|
24
|
+
_cset(:shared_files_path) { "#{shared_path}/files/"}
|
|
25
|
+
_cset(:document_root) { "#{homedir}#{client}/#{project}" }
|
|
20
26
|
|
|
21
|
-
set
|
|
22
|
-
set
|
|
23
|
-
set :deploy_to,"/home/sites/apps/#{client}/#{application}"
|
|
24
|
-
set :document_root, "/home/sites/#{client}/#{application}"
|
|
27
|
+
set(:application) { project }
|
|
28
|
+
set(:deploy_to) { "#{homedir}#{app_path}"}
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
role(:app) { app_servers }
|
|
31
|
+
role(:web) { web_servers }
|
|
32
|
+
role(:db, :primary => true) { db_server }
|
|
27
33
|
|
|
28
34
|
namespace :sumodev do
|
|
29
35
|
namespace :db do
|
|
@@ -31,12 +37,16 @@ configuration.load do
|
|
|
31
37
|
task :create, :roles => :db do
|
|
32
38
|
run "create_db #{db_name}"
|
|
33
39
|
end
|
|
40
|
+
|
|
41
|
+
desc "Dump the remote database, and outputs the content so you can pipe it"
|
|
42
|
+
task :dump, :roles => :db do
|
|
43
|
+
system %{ssh sites@#{db_server} mysqldump --set-charset #{db_name}}
|
|
44
|
+
end
|
|
34
45
|
|
|
35
46
|
desc "Imports the database from the server into your local database"
|
|
36
47
|
task :get, :roles => :db do
|
|
37
|
-
# @todo Defv
|
|
38
|
-
system %{
|
|
39
|
-
system %{ssh sites@dev.sumocoders.eu mysqldump --set-charset #{db_name} | mysql #{db_name}}
|
|
48
|
+
system %{mysqladmin create #{db_name}} # @todo Defv ignore errors
|
|
49
|
+
system %{ssh sites@#{db_server} mysqldump --set-charset #{db_name} | mysql #{db_name}}
|
|
40
50
|
end
|
|
41
51
|
|
|
42
52
|
desc "Get database info"
|
|
@@ -46,9 +56,8 @@ configuration.load do
|
|
|
46
56
|
|
|
47
57
|
desc "Imports the database from your local server to the remote one"
|
|
48
58
|
task :put, :roles => :db do
|
|
49
|
-
|
|
50
|
-
system %{
|
|
51
|
-
system %{mysqldump --set-charset #{db_name} | ssh sites@dev.sumocoders.eu mysql #{db_name}}
|
|
59
|
+
system %{ssh sites@#{db_server} "mysqldump --set-charset #{$db_name} > #{current_path}/#{release_name}.sql" }
|
|
60
|
+
system %{mysqldump --set-charset #{db_name} | ssh sites@#{db_server} #{db_name}}
|
|
52
61
|
end
|
|
53
62
|
end
|
|
54
63
|
|
|
@@ -65,13 +74,30 @@ configuration.load do
|
|
|
65
74
|
end until path.root?
|
|
66
75
|
end
|
|
67
76
|
|
|
77
|
+
def rsync(direction, from, to, options = {})
|
|
78
|
+
servers = find_servers_for_task(current_task)
|
|
79
|
+
servers = [servers.first] if options[:once]
|
|
80
|
+
|
|
81
|
+
servers.each do |server|
|
|
82
|
+
host_definition = "#{server.user || user}@#{server.host}"
|
|
83
|
+
host_definition << ":#{server.port}" if server.port && server.port != 22
|
|
84
|
+
|
|
85
|
+
case direction
|
|
86
|
+
when :down
|
|
87
|
+
run_locally "rsync -rtlpv #{host_definition}:#{from} #{to}"
|
|
88
|
+
when :up
|
|
89
|
+
run_locally "rsync -rtlp #{from} #{host_definition}:#{to}"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
68
94
|
desc "Sync all remote files to your local install"
|
|
69
95
|
task :get, :roles => :app do
|
|
70
96
|
path = find_folder_in_parents('frontend/files')
|
|
71
97
|
if !path
|
|
72
|
-
|
|
98
|
+
abort "No frontend/files folder found in this or upper folders. Are you sure you're in a Fork project?"
|
|
73
99
|
else
|
|
74
|
-
|
|
100
|
+
rsync :down, shared_files_path, path, :once => true
|
|
75
101
|
end
|
|
76
102
|
end
|
|
77
103
|
|
|
@@ -83,9 +109,9 @@ configuration.load do
|
|
|
83
109
|
# check if folder exists
|
|
84
110
|
path = find_folder_in_parents('frontend/files')
|
|
85
111
|
if !path
|
|
86
|
-
|
|
112
|
+
abort "No frontend/files folder found in this or upper folders. Are you sure you're in a Fork project?"
|
|
87
113
|
else
|
|
88
|
-
|
|
114
|
+
rsync :up, "#{path}/", shared_files_path
|
|
89
115
|
end
|
|
90
116
|
end
|
|
91
117
|
end
|
data/sumodev_deploy.gemspec
CHANGED