inploy 1.3.0 → 1.4.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/README.textile +3 -1
- data/Rakefile +1 -1
- data/lib/inploy.rb +2 -1
- data/lib/inploy/deploy.rb +22 -7
- data/lib/inploy/dsl.rb +56 -0
- data/lib/inploy/helper.rb +6 -43
- data/lib/inploy/servers/mongrel.rb +9 -0
- data/lib/inploy/servers/thin.rb +12 -0
- data/lib/inploy/templates/locaweb.rb +2 -2
- data/lib/inploy/templates/rails3.rb +9 -0
- metadata +20 -9
data/README.textile
CHANGED
@@ -23,6 +23,7 @@ Actually, Inploy has four rake tasks:
|
|
23
23
|
- installs gems
|
24
24
|
- migrates the database for the production environment
|
25
25
|
- cleans the cache in public/cache
|
26
|
+
- cleans cached assets in public/assets if jammit is installed
|
26
27
|
- parses less files if more:parse tasks exists
|
27
28
|
- package the assets if asset:packager:build_all task exists
|
28
29
|
- touch tmp/restart.txt
|
@@ -62,7 +63,8 @@ deploy.path = '/opt'
|
|
62
63
|
# OPTIONALS
|
63
64
|
|
64
65
|
deploy.ssh_opts = '-A' # default empty
|
65
|
-
deploy.branch = 'production' # default master
|
66
|
+
deploy.branch = 'production' # default master
|
67
|
+
deploy.sudo = true # default false</code></pre>
|
66
68
|
|
67
69
|
h2. LICENSE:
|
68
70
|
|
data/Rakefile
CHANGED
data/lib/inploy.rb
CHANGED
data/lib/inploy/deploy.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module Inploy
|
2
2
|
class Deploy
|
3
3
|
include Helper
|
4
|
-
|
5
|
-
attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch, :environment
|
4
|
+
include DSL
|
5
|
+
attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch, :environment, :port
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
self.server = :passenger
|
9
9
|
@branch = 'master'
|
10
10
|
@environment = 'production'
|
11
|
+
@sudo = ''
|
11
12
|
end
|
12
13
|
|
13
14
|
def template=(template)
|
@@ -18,30 +19,40 @@ module Inploy
|
|
18
19
|
load_module("servers/#{server}")
|
19
20
|
end
|
20
21
|
|
22
|
+
def sudo=(value)
|
23
|
+
@sudo = value.equal?(true) ? 'sudo ' : ''
|
24
|
+
end
|
25
|
+
|
21
26
|
def remote_setup
|
22
27
|
if branch.eql? "master"
|
23
28
|
checkout = ""
|
24
29
|
else
|
25
|
-
checkout = "&& $(
|
30
|
+
checkout = "&& $(git branch | grep -vq #{branch}) && git checkout -f -b #{branch} origin/#{branch}"
|
26
31
|
end
|
27
|
-
remote_run "cd #{path} && git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout} && rake inploy:local:setup environment=#{environment}"
|
32
|
+
remote_run "cd #{path} && #{@sudo}git clone --depth 1 #{repository} #{application} && cd #{application} #{checkout} && #{@sudo}rake inploy:local:setup environment=#{environment}"
|
28
33
|
end
|
29
34
|
|
30
35
|
def local_setup
|
31
36
|
create_folders 'tmp/pids', 'db'
|
37
|
+
copy_sample_files
|
38
|
+
rake "db:create RAILS_ENV=#{environment}"
|
32
39
|
run "./init.sh" if File.exists?("init.sh")
|
33
40
|
after_update_code
|
34
41
|
end
|
35
42
|
|
36
43
|
def remote_update
|
37
|
-
remote_run "cd #{application_path} && rake inploy:local:update environment=#{environment}"
|
44
|
+
remote_run "cd #{application_path} && #{@sudo}rake inploy:local:update environment=#{environment}"
|
38
45
|
end
|
39
46
|
|
40
47
|
def local_update
|
41
48
|
run "git pull origin #{branch}"
|
42
49
|
after_update_code
|
43
50
|
end
|
44
|
-
|
51
|
+
|
52
|
+
def before_restarting_server(&block)
|
53
|
+
@before_restarting_server = block
|
54
|
+
end
|
55
|
+
|
45
56
|
private
|
46
57
|
|
47
58
|
def after_update_code
|
@@ -49,11 +60,15 @@ module Inploy
|
|
49
60
|
copy_sample_files
|
50
61
|
install_gems
|
51
62
|
migrate_database
|
63
|
+
run "whenever --update-crontab #{application} --set 'environment=#{environment}'" if File.exists?("config/schedule.rb")
|
52
64
|
run "rm -R -f public/cache"
|
65
|
+
run "rm -R -f public/assets" if jammit_is_installed?
|
53
66
|
rake_if_included "more:parse"
|
54
67
|
rake_if_included "asset:packager:build_all"
|
55
68
|
rake_if_included "hoptoad:deploy TO=#{environment} REPO=#{repository} REVISION=#{`git log | head -1 | cut -d ' ' -f 2`}"
|
69
|
+
ruby_if_exists "vendor/plugins/newrelic_rpm/bin/newrelic_cmd", :params => "deployments"
|
70
|
+
instance_eval(&@before_restarting_server) unless @before_restarting_server.nil?
|
56
71
|
restart_server
|
57
|
-
end
|
72
|
+
end
|
58
73
|
end
|
59
74
|
end
|
data/lib/inploy/dsl.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Inploy
|
2
|
+
module DSL
|
3
|
+
def create_folder(path)
|
4
|
+
run "mkdir -p #{path}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_folders(*folders)
|
8
|
+
folders.each { |folder| create_folder folder }
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_module(filename)
|
12
|
+
require "inploy/#{filename}"
|
13
|
+
extend eval(filename.split("/").map { |word| camelize(word) }.join("::"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def log(command)
|
17
|
+
puts "Inploy => #{command}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def rake(command)
|
21
|
+
run "rake #{command}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def rake_if_included(command)
|
25
|
+
rake command if tasks.include?("rake #{command.split[0]}")
|
26
|
+
end
|
27
|
+
|
28
|
+
def ruby_if_exists(file, opts)
|
29
|
+
run "ruby #{file} #{opts[:params]}" if File.exists?(file)
|
30
|
+
end
|
31
|
+
|
32
|
+
def run(command, disable_sudo = false)
|
33
|
+
log command
|
34
|
+
|
35
|
+
if disable_sudo
|
36
|
+
Kernel.system command
|
37
|
+
else
|
38
|
+
Kernel.system "#{@sudo}#{command}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def remote_run(command)
|
43
|
+
port_opts = port ? "-p #{port} " : ''
|
44
|
+
hosts.each do |host|
|
45
|
+
run "ssh #{ssh_opts} #{port_opts}#{user}@#{host} '#{command}'", true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def secure_copy(src, dest)
|
50
|
+
unless File.exists?(dest)
|
51
|
+
log "mv #{src} #{dest}"
|
52
|
+
FileUtils.cp src, dest
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/inploy/helper.rb
CHANGED
@@ -1,16 +1,7 @@
|
|
1
1
|
module Inploy
|
2
2
|
module Helper
|
3
|
-
def
|
4
|
-
|
5
|
-
extend eval(filename.split("/").map { |word| camelize(word) }.join("::"))
|
6
|
-
end
|
7
|
-
|
8
|
-
def create_folders(*folders)
|
9
|
-
folders.each { |folder| create_folder folder }
|
10
|
-
end
|
11
|
-
|
12
|
-
def create_folder(path)
|
13
|
-
run "mkdir -p #{path}"
|
3
|
+
def jammit_is_installed?
|
4
|
+
File.exists?("config/assets.yml")
|
14
5
|
end
|
15
6
|
|
16
7
|
def host
|
@@ -26,15 +17,10 @@ module Inploy
|
|
26
17
|
end
|
27
18
|
|
28
19
|
def copy_sample_files
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def secure_copy(src, dest)
|
35
|
-
unless File.exists?(dest)
|
36
|
-
log "mv #{src} #{dest}"
|
37
|
-
FileUtils.cp src, dest
|
20
|
+
["example", "sample"].each do |extension|
|
21
|
+
Dir.glob("config/*.#{extension}").each do |file|
|
22
|
+
secure_copy file, file.gsub(".#{extension}", '')
|
23
|
+
end
|
38
24
|
end
|
39
25
|
end
|
40
26
|
|
@@ -46,29 +32,6 @@ module Inploy
|
|
46
32
|
`rake -T`
|
47
33
|
end
|
48
34
|
|
49
|
-
def rake_if_included(command)
|
50
|
-
rake command if tasks.include?("rake #{command.split[0]}")
|
51
|
-
end
|
52
|
-
|
53
|
-
def rake(command)
|
54
|
-
run "rake #{command}"
|
55
|
-
end
|
56
|
-
|
57
|
-
def remote_run(command)
|
58
|
-
hosts.each do |host|
|
59
|
-
run "ssh #{ssh_opts} #{user}@#{host} '#{command}'"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def run(command)
|
64
|
-
log command
|
65
|
-
Kernel.system command
|
66
|
-
end
|
67
|
-
|
68
|
-
def log(command)
|
69
|
-
puts "Inploy => #{command}"
|
70
|
-
end
|
71
|
-
|
72
35
|
def install_gems
|
73
36
|
rake "gems:install RAILS_ENV=#{environment}"
|
74
37
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Inploy
|
2
|
+
module Servers
|
3
|
+
module Thin
|
4
|
+
def restart_server
|
5
|
+
run "thin --pid tmp/pids/thin.pid stop"
|
6
|
+
run "thin --rackup config.ru --daemonize\
|
7
|
+
--log log/thin.log --pid tmp/pids/thin.pid --environment production\
|
8
|
+
--port 4500 start"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -6,8 +6,8 @@ module Inploy
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def remote_update
|
9
|
-
run "git push ssh://[#{user}@#{host}]#{application_path}
|
10
|
-
|
9
|
+
run "git push ssh://[#{user}@#{host}#{port ? ":#{port}" : ''}]#{application_path} #{branch}"
|
10
|
+
remote_run "cd #{application_path} && git checkout -f && rake inploy:local:update environment=#{environment}"
|
11
11
|
end
|
12
12
|
|
13
13
|
def local_setup
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 1.4.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Diego Carrion
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-03-23 00:00:00 -03:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -22,15 +27,19 @@ extensions: []
|
|
22
27
|
extra_rdoc_files: []
|
23
28
|
|
24
29
|
files:
|
25
|
-
- lib/tasks/inploy.rake
|
26
30
|
- lib/inploy/deploy.rb
|
27
|
-
- lib/inploy/
|
31
|
+
- lib/inploy/dsl.rb
|
32
|
+
- lib/inploy/helper.rb
|
33
|
+
- lib/inploy/servers/mongrel.rb
|
28
34
|
- lib/inploy/servers/passenger.rb
|
35
|
+
- lib/inploy/servers/thin.rb
|
36
|
+
- lib/inploy/servers/unicorn.rb
|
29
37
|
- lib/inploy/templates/locaweb.rb
|
30
|
-
- lib/inploy/
|
38
|
+
- lib/inploy/templates/rails3.rb
|
31
39
|
- lib/inploy.rb
|
32
|
-
-
|
40
|
+
- lib/tasks/inploy.rake
|
33
41
|
- Rakefile
|
42
|
+
- README.textile
|
34
43
|
has_rdoc: true
|
35
44
|
homepage: http://www.diegocarrion.com
|
36
45
|
licenses: []
|
@@ -44,18 +53,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
53
|
requirements:
|
45
54
|
- - ">="
|
46
55
|
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
47
58
|
version: "0"
|
48
|
-
version:
|
49
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
60
|
requirements:
|
51
61
|
- - ">="
|
52
62
|
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
53
65
|
version: "0"
|
54
|
-
version:
|
55
66
|
requirements: []
|
56
67
|
|
57
68
|
rubyforge_project: inploy
|
58
|
-
rubygems_version: 1.3.
|
69
|
+
rubygems_version: 1.3.6
|
59
70
|
signing_key:
|
60
71
|
specification_version: 3
|
61
72
|
summary: Rails deployment made easy
|