capifony 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README +35 -9
- data/lib/capifony.rb +47 -12
- metadata +4 -4
data/CHANGELOG
CHANGED
data/README
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
Deploying symfony Applications with Capistrano
|
2
|
-
|
2
|
+
==============================================
|
3
3
|
|
4
4
|
Capistrano is an open source tool for running scripts on multiple servers. It’s primary use is for easily deploying applications. While it was built specifically for deploying Rails apps, it’s pretty simple to customize it to deploy other types of applications. We’ve been working on creating a deployment “recipe” to work with symfony applications to make our job a lot easier.
|
5
5
|
|
6
|
-
|
6
|
+
Prerequisites
|
7
|
+
-------------
|
7
8
|
|
8
9
|
- Must have SSH access to the server you are deploying to.
|
9
10
|
- Must have Ruby and RubyGems installed on your machine (not required for deployment server)’
|
10
11
|
|
11
|
-
|
12
|
+
Installing Capifony
|
13
|
+
-------------------
|
14
|
+
|
15
|
+
### Through RubyGems.org ###
|
12
16
|
|
13
17
|
sudo gem install capifony
|
14
18
|
|
15
|
-
###
|
19
|
+
### Through GitHub ###
|
20
|
+
|
21
|
+
git clone git://github.com/everzet/capifony.git
|
22
|
+
cd capifony
|
23
|
+
gem build capifony.gemspec
|
24
|
+
sudo gem install capifony-{version}.gem
|
25
|
+
|
26
|
+
Setup your project to use Capifony
|
27
|
+
----------------------------------
|
16
28
|
|
17
29
|
CD to your project directory & run:
|
18
30
|
|
@@ -22,7 +34,8 @@ This will create `Capfile` in your project root & `deploy.rb` config file in `co
|
|
22
34
|
|
23
35
|
Fill up your `config/deploy.rb` with your server connection data
|
24
36
|
|
25
|
-
|
37
|
+
Server Setup
|
38
|
+
------------
|
26
39
|
|
27
40
|
Now, you can start the deployment process! To get your server setup with the file structure that Capistrano expects, you can run:
|
28
41
|
|
@@ -47,7 +60,8 @@ To deploy your application, simply run:
|
|
47
60
|
|
48
61
|
cap deploy
|
49
62
|
|
50
|
-
|
63
|
+
Deployment
|
64
|
+
----------
|
51
65
|
|
52
66
|
To configure database on production environment, run:
|
53
67
|
|
@@ -63,7 +77,16 @@ Now, whenever you need to deploy a new version of your code, just run:
|
|
63
77
|
|
64
78
|
cap deploy
|
65
79
|
|
66
|
-
|
80
|
+
Databases
|
81
|
+
---------
|
82
|
+
|
83
|
+
If you need to dump remote database & download this dump to local `backups/` folder, run:
|
84
|
+
|
85
|
+
cap database:dump:remote
|
86
|
+
|
87
|
+
If you need to dump local database & put this dump to local `backups/` folder, run:
|
88
|
+
|
89
|
+
cap database:dump:local
|
67
90
|
|
68
91
|
If you need to dump remote database & populate this dump on local machine, run:
|
69
92
|
|
@@ -73,7 +96,8 @@ If you need to dump local database & populate this dump on remote server, run:
|
|
73
96
|
|
74
97
|
cap database:move:to_remote
|
75
98
|
|
76
|
-
|
99
|
+
Shared folders
|
100
|
+
--------------
|
77
101
|
|
78
102
|
If you need to download some shared folders from remote server, run:
|
79
103
|
|
@@ -83,7 +107,8 @@ If you need to upload some shared folders to remote server, run:
|
|
83
107
|
|
84
108
|
cap shared:{databases OR log OR uploads]:to_remote
|
85
109
|
|
86
|
-
|
110
|
+
Other tasks
|
111
|
+
-----------
|
87
112
|
|
88
113
|
If you need to deploy and run your migrations you can call:
|
89
114
|
|
@@ -110,3 +135,4 @@ Contributors
|
|
110
135
|
|
111
136
|
* everzet (owner): [http://github.com/everzet](http://github.com/everzet)
|
112
137
|
* Travis Roberts (creator of improved version): [http://blog.centresource.com/author/troberts/](http://blog.centresource.com/author/troberts/)
|
138
|
+
* Arlo (contributor): [http://github.com/arlo](http://github.com/arlo)
|
data/lib/capifony.rb
CHANGED
@@ -50,6 +50,7 @@ namespace :deploy do
|
|
50
50
|
task :create_dirs do
|
51
51
|
if shared_children
|
52
52
|
shared_children.each do |link|
|
53
|
+
run "test -d #{release_path}/#{link} && rm -rf #{release_path}/#{link}"
|
53
54
|
run "mkdir -p #{shared_path}/#{link}"
|
54
55
|
run "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}"
|
55
56
|
end
|
@@ -200,10 +201,10 @@ namespace :doctrine do
|
|
200
201
|
end
|
201
202
|
|
202
203
|
namespace :database do
|
203
|
-
namespace :
|
204
|
-
desc "Dump remote database
|
205
|
-
task :
|
206
|
-
filename = "#{application}.
|
204
|
+
namespace :dump do
|
205
|
+
desc "Dump remote database"
|
206
|
+
task :remote do
|
207
|
+
filename = "#{application}.remote_dump.#{Time.now.to_i}.sql.bz2"
|
207
208
|
file = "/tmp/#{filename}"
|
208
209
|
sqlfile = "#{application}_dump.sql"
|
209
210
|
config = ""
|
@@ -217,34 +218,64 @@ namespace :database do
|
|
217
218
|
run "mysqldump -u#{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}" do |ch, stream, data|
|
218
219
|
puts data
|
219
220
|
end
|
221
|
+
when 'pgsql'
|
222
|
+
run "pg_dump -U #{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}" do |ch, stream, data|
|
223
|
+
puts data
|
224
|
+
end
|
220
225
|
end
|
221
226
|
|
222
227
|
`mkdir -p backups`
|
223
228
|
get file, "backups/#{filename}"
|
229
|
+
`cd backups && ln -nfs #{filename} #{application}.remote_dump.latest.sql.bz2`
|
224
230
|
run "rm #{file}"
|
231
|
+
end
|
225
232
|
|
226
|
-
|
233
|
+
desc "Dump local database"
|
234
|
+
task :local do
|
235
|
+
filename = "#{application}.local_dump.#{Time.now.to_i}.sql.bz2"
|
236
|
+
file = "backups/#{filename}"
|
237
|
+
config = load_database_config IO.read('config/databases.yml'), 'dev'
|
238
|
+
sqlfile = "#{application}_dump.sql"
|
239
|
+
|
240
|
+
`mkdir -p backups`
|
241
|
+
case config['type']
|
242
|
+
when 'mysql'
|
243
|
+
`mysqldump -u#{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}`
|
244
|
+
when 'pgsql'
|
245
|
+
`pg_dump -U #{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}`
|
246
|
+
end
|
247
|
+
|
248
|
+
`cd backups && ln -nfs #{filename} #{application}.local_dump.latest.sql.bz2`
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
namespace :move do
|
253
|
+
desc "Dump remote database, download it to local & populate here"
|
254
|
+
task :to_local do
|
255
|
+
filename = "#{application}.remote_dump.latest.sql.bz2"
|
256
|
+
config = load_database_config IO.read('config/databases.yml'), 'dev'
|
257
|
+
sqlfile = "#{application}_dump.sql"
|
258
|
+
|
259
|
+
database.dump.remote
|
227
260
|
|
228
261
|
`bunzip2 -kc backups/#{filename} > backups/#{sqlfile}`
|
229
262
|
case config['type']
|
230
263
|
when 'mysql'
|
231
264
|
`mysql -u#{config['user']} --password='#{config['pass']}' #{config['db']} < backups/#{sqlfile}`
|
265
|
+
when 'pgsql'
|
266
|
+
`psql -U #{config['user']} --password='#{config['pass']}' #{config['db']} < backups/#{sqlfile}`
|
232
267
|
end
|
233
268
|
`rm backups/#{sqlfile}`
|
234
269
|
end
|
235
270
|
|
236
271
|
desc "Dump local database, load it to remote & populate there"
|
237
272
|
task :to_remote do
|
238
|
-
filename = "#{application}.local_dump
|
273
|
+
filename = "#{application}.local_dump.latest.sql.bz2"
|
239
274
|
file = "backups/#{filename}"
|
240
|
-
config = load_database_config IO.read('config/databases.yml'), 'dev'
|
241
275
|
sqlfile = "#{application}_dump.sql"
|
276
|
+
config = ""
|
242
277
|
|
243
|
-
|
244
|
-
case config['type']
|
245
|
-
when 'mysql'
|
246
|
-
`mysqldump -u#{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}`
|
247
|
-
end
|
278
|
+
database.dump.local
|
248
279
|
|
249
280
|
upload(file, "/tmp/#{filename}", :via => :scp)
|
250
281
|
run "bunzip2 -kc /tmp/#{filename} > /tmp/#{sqlfile}"
|
@@ -258,6 +289,10 @@ namespace :database do
|
|
258
289
|
run "mysql -u#{config['user']} --password='#{config['pass']}' #{config['db']} < /tmp/#{sqlfile}" do |ch, stream, data|
|
259
290
|
puts data
|
260
291
|
end
|
292
|
+
when 'pgsql'
|
293
|
+
run "psql -U #{config['user']} --password='#{config['pass']}' #{config['db']} < /tmp/#{sqlfile}" do |ch, stream, data|
|
294
|
+
puts data
|
295
|
+
end
|
261
296
|
end
|
262
297
|
|
263
298
|
run "rm /tmp/#{filename}"
|
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Konstantin Kudryashov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-11 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|