inploy 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +30 -6
- data/Rakefile +1 -1
- data/lib/inploy/deploy.rb +13 -7
- data/lib/inploy/helper.rb +18 -2
- data/lib/tasks/inploy.rake +10 -1
- metadata +4 -4
data/README.textile
CHANGED
@@ -10,7 +10,7 @@ Actually, Inploy has four rake tasks:
|
|
10
10
|
- clones a git repository
|
11
11
|
- runs inploy:local:setup
|
12
12
|
|
13
|
-
* inploy:remote:update
|
13
|
+
* inploy:remote:update (_alias: inploy:up_)
|
14
14
|
|
15
15
|
- connects to a list of servers
|
16
16
|
- runs inploy:local:update
|
@@ -33,11 +33,25 @@ Actually, Inploy has four rake tasks:
|
|
33
33
|
- pulls the repository
|
34
34
|
- installs gems
|
35
35
|
- migrates the database for the production environment
|
36
|
-
- cleans the cache
|
36
|
+
- cleans the cache directories (default public/cache)
|
37
37
|
- parses less files if more:parse tasks exists
|
38
38
|
- package the assets if asset:packager:build_all task exists
|
39
39
|
- touch tmp/restart.txt
|
40
40
|
|
41
|
+
h2. SKIP STEPS
|
42
|
+
|
43
|
+
You can skip some steps when running a task, just add "skip_steps" into your rake command line or add "skip_steps" to your deploy.rb to always skip those steps (see "CONFIGURATION" for details).
|
44
|
+
|
45
|
+
Currently the steps available to skip are:
|
46
|
+
|
47
|
+
- install_gems: skip rake gems:install
|
48
|
+
- migrate_database: skip rake db:migrate
|
49
|
+
- clear_cache: skip removing cache directories
|
50
|
+
|
51
|
+
* Usage (params are comma separated):
|
52
|
+
|
53
|
+
<pre><code>rake inploy:remote:update skip_steps=install_gems,migrate_database</code></pre>
|
54
|
+
|
41
55
|
h2. INSTALLATION:
|
42
56
|
|
43
57
|
As a plugin:
|
@@ -54,7 +68,8 @@ h2. CONFIGURATION
|
|
54
68
|
|
55
69
|
Create a config/deploy.rb file and configure it something like this:
|
56
70
|
|
57
|
-
<pre><code>
|
71
|
+
<pre><code>
|
72
|
+
deploy.application = "signal"
|
58
73
|
deploy.repository = 'git://github.com/dcrec1/signal.git'
|
59
74
|
deploy.user = 'dcrec1'
|
60
75
|
deploy.hosts = ['hooters', 'geni']
|
@@ -62,9 +77,18 @@ deploy.path = '/opt'
|
|
62
77
|
|
63
78
|
# OPTIONALS
|
64
79
|
|
65
|
-
deploy.ssh_opts = '-A'
|
66
|
-
deploy.branch = 'production'
|
67
|
-
deploy.sudo = true
|
80
|
+
deploy.ssh_opts = '-A' # default empty
|
81
|
+
deploy.branch = 'production' # default master
|
82
|
+
deploy.sudo = true # default false
|
83
|
+
deploy.cache_dirs = ['public/cache', 'tmp/cache'] # default ['public/cache']
|
84
|
+
|
85
|
+
# Use this if you want to skip some steps on update and setup
|
86
|
+
# Available options: install_gems, migrate_database, clear_cache
|
87
|
+
# This feature is also available on command line
|
88
|
+
# eg. rake inploy:update:remote skip_steps=install_gems
|
89
|
+
|
90
|
+
deploy.skip_steps = ['install_gems', 'clear_cache'] #default none
|
91
|
+
</code></pre>
|
68
92
|
|
69
93
|
h2. LICENSE:
|
70
94
|
|
data/Rakefile
CHANGED
data/lib/inploy/deploy.rb
CHANGED
@@ -2,26 +2,32 @@ module Inploy
|
|
2
2
|
class Deploy
|
3
3
|
include Helper
|
4
4
|
include DSL
|
5
|
-
attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch, :environment,
|
5
|
+
attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch, :environment,
|
6
|
+
:port, :skip_steps, :cache_dirs
|
6
7
|
|
7
8
|
def initialize
|
8
9
|
self.server = :passenger
|
10
|
+
self.cache_dirs ||= ['public/cache']
|
9
11
|
@branch = 'master'
|
10
12
|
@environment = 'production'
|
11
13
|
@sudo = ''
|
12
14
|
end
|
13
15
|
|
14
16
|
def template=(template)
|
15
|
-
load_module
|
17
|
+
load_module "templates/#{template}"
|
16
18
|
end
|
17
19
|
|
18
20
|
def server=(server)
|
19
|
-
load_module
|
21
|
+
load_module "servers/#{server}"
|
20
22
|
end
|
21
23
|
|
22
24
|
def sudo=(value)
|
23
25
|
@sudo = value.equal?(true) ? 'sudo ' : ''
|
24
26
|
end
|
27
|
+
|
28
|
+
def remote_install(opts)
|
29
|
+
remote_run "bash < <(wget -O- #{opts[:from]})"
|
30
|
+
end
|
25
31
|
|
26
32
|
def remote_setup
|
27
33
|
if branch.eql? "master"
|
@@ -29,7 +35,7 @@ module Inploy
|
|
29
35
|
else
|
30
36
|
checkout = "&& $(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch}"
|
31
37
|
end
|
32
|
-
remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout} && #{@sudo}rake inploy:local:setup environment=#{environment}"
|
38
|
+
remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout} && #{@sudo}rake inploy:local:setup environment=#{environment}#{skip_steps_cmd}"
|
33
39
|
end
|
34
40
|
|
35
41
|
def local_setup
|
@@ -41,7 +47,7 @@ module Inploy
|
|
41
47
|
end
|
42
48
|
|
43
49
|
def remote_update
|
44
|
-
remote_run "cd #{application_path} && #{@sudo}rake inploy:local:update environment=#{environment}"
|
50
|
+
remote_run "cd #{application_path} && #{@sudo}rake inploy:local:update environment=#{environment}#{skip_steps_cmd}"
|
45
51
|
end
|
46
52
|
|
47
53
|
def local_update
|
@@ -61,11 +67,11 @@ module Inploy
|
|
61
67
|
install_gems
|
62
68
|
migrate_database
|
63
69
|
run "whenever --update-crontab #{application} --set 'environment=#{environment}'" if File.exists?("config/schedule.rb")
|
64
|
-
|
70
|
+
clear_cache
|
65
71
|
run "rm -R -f public/assets" if jammit_is_installed?
|
66
72
|
rake_if_included "more:parse"
|
67
73
|
rake_if_included "asset:packager:build_all"
|
68
|
-
rake_if_included "hoptoad:deploy TO=#{environment} REPO=#{repository} REVISION=#{`git log | head -1 | cut -d ' ' -f 2`}"
|
74
|
+
rake_if_included "hoptoad:deploy RAILS_ENV=#{environment} TO=#{environment} REPO=#{repository} REVISION=#{`git log | head -1 | cut -d ' ' -f 2`}"
|
69
75
|
ruby_if_exists "vendor/plugins/newrelic_rpm/bin/newrelic_cmd", :params => "deployments"
|
70
76
|
instance_eval(&@before_restarting_server) unless @before_restarting_server.nil?
|
71
77
|
restart_server
|
data/lib/inploy/helper.rb
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
module Inploy
|
2
2
|
module Helper
|
3
|
+
def skip_step?(step)
|
4
|
+
skip_steps and skip_steps.include?(step)
|
5
|
+
end
|
6
|
+
|
7
|
+
def skip_steps_cmd
|
8
|
+
" skip_steps=#{skip_steps.join(',')}" unless skip_steps.nil?
|
9
|
+
end
|
10
|
+
|
11
|
+
def clear_cache
|
12
|
+
unless skip_step?('clear_cache')
|
13
|
+
cache_dirs.each do |dir|
|
14
|
+
run "rm -R -f #{dir}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
3
19
|
def jammit_is_installed?
|
4
20
|
File.exists?("config/assets.yml")
|
5
21
|
end
|
@@ -25,7 +41,7 @@ module Inploy
|
|
25
41
|
end
|
26
42
|
|
27
43
|
def migrate_database
|
28
|
-
rake "db:migrate RAILS_ENV=#{environment}"
|
44
|
+
rake "db:migrate RAILS_ENV=#{environment}" unless skip_step?('migrate_database')
|
29
45
|
end
|
30
46
|
|
31
47
|
def tasks
|
@@ -33,7 +49,7 @@ module Inploy
|
|
33
49
|
end
|
34
50
|
|
35
51
|
def install_gems
|
36
|
-
rake "gems:install RAILS_ENV=#{environment}"
|
52
|
+
rake "gems:install RAILS_ENV=#{environment}" unless skip_step?('install_gems')
|
37
53
|
end
|
38
54
|
end
|
39
55
|
end
|
data/lib/tasks/inploy.rake
CHANGED
@@ -12,6 +12,7 @@ end
|
|
12
12
|
|
13
13
|
|
14
14
|
deploy.environment = ENV['environment'] || deploy.environment
|
15
|
+
deploy.skip_steps = ENV['skip_steps'].split(',') unless ENV['skip_steps'].nil?
|
15
16
|
|
16
17
|
namespace :inploy do
|
17
18
|
namespace :local do
|
@@ -27,14 +28,22 @@ namespace :inploy do
|
|
27
28
|
end
|
28
29
|
|
29
30
|
namespace :remote do
|
31
|
+
desc "Remote install"
|
32
|
+
task :install do
|
33
|
+
deploy.remote_install :from => ENV['from']
|
34
|
+
end
|
35
|
+
|
30
36
|
desc "Remote Setup"
|
31
37
|
task :setup do
|
32
38
|
deploy.remote_setup
|
33
39
|
end
|
34
40
|
|
35
41
|
desc "Remote Update"
|
36
|
-
task :update do
|
42
|
+
task :update do
|
37
43
|
deploy.remote_update
|
38
44
|
end
|
39
45
|
end
|
46
|
+
|
47
|
+
desc "Alias to Remote Update"
|
48
|
+
task :up => "remote:update"
|
40
49
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 1.
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 1.5.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Diego Carrion
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-15 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|