inploy 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +111 -48
- data/Rakefile +3 -3
- data/bin/inploy +7 -0
- data/lib/inploy/cli.rb +15 -0
- data/lib/inploy/deploy.rb +14 -5
- data/lib/inploy/dsl.rb +5 -1
- data/lib/inploy/helper.rb +4 -0
- data/lib/inploy/templates/locaweb.rb +4 -0
- data/lib/inploy/templates/rails3.rb +0 -1
- data/lib/tasks/inploy.rake +1 -9
- metadata +7 -5
data/README.textile
CHANGED
@@ -1,100 +1,163 @@
|
|
1
1
|
h2. ABOUT:
|
2
2
|
|
3
|
-
Inploy
|
3
|
+
Inploy was a born as an option to setup and deploy Rails applications in an easier and smarter way.
|
4
4
|
|
5
|
-
|
5
|
+
It executes common tasks like migrate the database, install gems, package the assets, clean the cache, notified Hoptoad, restart the server, etc. automatically. This means you will not have a big deploy script calld 'recipe' like with other tools, only a simple deploy script with a few lines.
|
6
|
+
|
7
|
+
It uses Git to version the deploys and to pull only the modifications in each one. This means you will not have a lot of folders in the server (only one) with duplicated code and that ech deploy will be very fast.
|
8
|
+
|
9
|
+
It is very flexible, meaning you can create templates specifing how specific tasks must behave. As today, there are templates for Locaweb and for Rails 3.
|
10
|
+
|
11
|
+
It works by default with Passenger, but you can specified another servers like Mongrel, Thin and Unicorn.
|
12
|
+
|
13
|
+
You can execute Inploy from a remote machine or from the server machine, meaning anynone can go to the deployment path and with only one command update the code and execute all the tasks.
|
14
|
+
|
15
|
+
As Inploy is very flexible, now you can also use it to execute an installation shell script in a server from an URL.
|
16
|
+
|
17
|
+
h2. INSTALLATION:
|
18
|
+
|
19
|
+
As a plugin:
|
20
|
+
|
21
|
+
<pre><code>script/plugin install git://github.com/dcrec1/inploy.git</code></pre>
|
22
|
+
|
23
|
+
As a gem:
|
24
|
+
|
25
|
+
<pre><code>sudo gem install inploy</code></pre>
|
26
|
+
|
27
|
+
Please remember that when used as a gem, Inploy should be available in the deploy servers.
|
28
|
+
|
29
|
+
h2. USAGE
|
30
|
+
|
31
|
+
When using Inploy with Rake, there are five tasks:
|
32
|
+
|
33
|
+
* inploy:remote:install from=url
|
34
|
+
|
35
|
+
- connects to a list of servers and executes the script from url
|
6
36
|
|
7
37
|
* inploy:remote:setup
|
8
38
|
|
9
39
|
- connects to a list of servers
|
10
40
|
- clones a git repository
|
11
|
-
-
|
41
|
+
- executes rake inploy:local:setup
|
12
42
|
|
13
|
-
* inploy:remote:update
|
43
|
+
* inploy:remote:update or inploy:up
|
14
44
|
|
15
45
|
- connects to a list of servers
|
16
|
-
-
|
46
|
+
- executes inploy:local:update
|
47
|
+
|
48
|
+
* inploy:remote:install
|
49
|
+
|
50
|
+
- connects to a list of servers
|
51
|
+
- reads the content of url specified by from=url without downloading the file and executes it
|
17
52
|
|
18
53
|
* inploy:local:setup
|
19
54
|
|
20
|
-
-
|
21
|
-
-
|
55
|
+
- creates directories db and tmp/pids
|
56
|
+
- copies config/*.sample and config/*.example files to config/*
|
57
|
+
- creates the database
|
22
58
|
- executes init.sh file case it exists
|
59
|
+
- inits and updates the git submodules
|
23
60
|
- installs gems
|
24
|
-
- migrates the database
|
25
|
-
-
|
26
|
-
- cleans
|
61
|
+
- migrates the database
|
62
|
+
- updates the crontab from Whenever if being used
|
63
|
+
- cleans the cache, default tmp/cache
|
64
|
+
- cleans cached assets in public/assets if Jammit is installed
|
27
65
|
- parses less files if more:parse tasks exists
|
28
66
|
- package the assets if asset:packager:build_all task exists
|
29
|
-
-
|
67
|
+
- notifies Hoptoad about the deploy, specifing the revision, repository and environment
|
68
|
+
- notifies NewRelic RPM about the deploy
|
69
|
+
- restarts the server
|
30
70
|
|
31
71
|
* inploy:local:update
|
32
72
|
|
33
73
|
- pulls the repository
|
74
|
+
- inits and updates the git submodules
|
75
|
+
- copies config/*.sample and config/*.example files to config/*
|
34
76
|
- installs gems
|
35
|
-
- migrates the database
|
36
|
-
-
|
77
|
+
- migrates the database
|
78
|
+
- updates the crontab from Whenever if being used
|
79
|
+
- cleans the cache, default tmp/cache
|
80
|
+
- cleans cached assets in public/assets if Jammit is installed
|
37
81
|
- parses less files if more:parse tasks exists
|
38
82
|
- package the assets if asset:packager:build_all task exists
|
39
|
-
-
|
83
|
+
- notifies Hoptoad about the deploy, specifing the revision, repository and environment
|
84
|
+
- notifies NewRelic RPM about the deploy
|
85
|
+
- restarts the server
|
40
86
|
|
41
|
-
|
87
|
+
If you don't want to execute Rake, there are a few shortcuts:
|
42
88
|
|
43
|
-
|
89
|
+
inploy = inploy update = rake inploy:remote:update
|
90
|
+
inploy install from=url = rake inploy:remote:install from=url
|
44
91
|
|
45
|
-
|
92
|
+
When using inploy as a command, it looks first for config/deploy.rb and then for deploy.rb .
|
46
93
|
|
47
|
-
|
48
|
-
- migrate_database: skip rake db:migrate
|
49
|
-
- clear_cache: skip removing cache directories
|
94
|
+
h2. CONFIGURATION
|
50
95
|
|
51
|
-
|
96
|
+
Create a config/deploy.rb file and configure it something like this:
|
52
97
|
|
53
|
-
<pre><code>
|
98
|
+
<pre><code>
|
99
|
+
application = "signal"
|
100
|
+
repository = 'git://github.com/dcrec1/signal.git'
|
101
|
+
hosts = ['hooters', 'geni']
|
54
102
|
|
55
|
-
|
103
|
+
# OPTIONALS
|
56
104
|
|
57
|
-
|
105
|
+
before_restarting_server do
|
106
|
+
rake "important:task"
|
107
|
+
run "important_command"
|
108
|
+
end
|
109
|
+
|
110
|
+
path = '/opt' # default /var/local/apps
|
111
|
+
user = 'dcrec1' # default deploy
|
112
|
+
ssh_opts = '-A' # default empty
|
113
|
+
branch = 'production' # default master
|
114
|
+
sudo = true # default false
|
115
|
+
cache_dirs = ['public/cache', 'tmp/cache'] # default ['public/cache']
|
116
|
+
skip_steps = ['install_gems', 'clear_cache'] # default []
|
117
|
+
</code></pre>
|
58
118
|
|
59
|
-
|
119
|
+
h2. SKIP STEPS
|
60
120
|
|
61
|
-
|
121
|
+
You can skip some steps when running a Rake task, just add "skip_steps" into your rake command line or add "skip_steps" to your deploy.rb to always skip those steps.
|
62
122
|
|
63
|
-
|
123
|
+
Currently the steps available to skip are:
|
64
124
|
|
65
|
-
|
125
|
+
- install_gems: skip rake gems:install
|
126
|
+
- migrate_database: skip rake db:migrate
|
127
|
+
- clear_cache: skip removing cache directories
|
66
128
|
|
67
|
-
|
129
|
+
* Usage (params are comma separated):
|
68
130
|
|
69
|
-
|
131
|
+
<pre><code>rake inploy:remote:update skip_steps=install_gems,migrate_database</code></pre>
|
70
132
|
|
71
|
-
|
72
|
-
deploy.application = "signal"
|
73
|
-
deploy.repository = 'git://github.com/dcrec1/signal.git'
|
74
|
-
deploy.user = 'dcrec1'
|
75
|
-
deploy.hosts = ['hooters', 'geni']
|
76
|
-
deploy.path = '/opt'
|
133
|
+
h2. HOOKS
|
77
134
|
|
78
|
-
|
135
|
+
Currently the only hook is called before restarting the server. If you need another hook, please fork the project and implemented it or created an issue, it's very easy.
|
79
136
|
|
80
|
-
|
81
|
-
deploy.branch = 'production' # default master
|
82
|
-
deploy.sudo = true # default false
|
83
|
-
deploy.cache_dirs = ['public/cache', 'tmp/cache'] # default ['public/cache']
|
137
|
+
h2. CONTRIBUTORS:
|
84
138
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
139
|
+
Inploy is brought to you by:
|
140
|
+
|
141
|
+
* Diego Carrion
|
142
|
+
* Douglas Campos
|
143
|
+
* Kristopher Murata
|
144
|
+
* Vitor Pellegrino
|
145
|
+
* Josh Owens
|
146
|
+
* Felipe
|
147
|
+
* trooster
|
148
|
+
* Josef Pospíšil
|
149
|
+
* BrunoGrasselli
|
150
|
+
* Andy Shen
|
151
|
+
* alekenji
|
152
|
+
* Erik Dahlstrand
|
153
|
+
* Carlos Brando
|
89
154
|
|
90
|
-
deploy.skip_steps = ['install_gems', 'clear_cache'] #default none
|
91
|
-
</code></pre>
|
92
155
|
|
93
156
|
h2. LICENSE:
|
94
157
|
|
95
158
|
(The MIT License)
|
96
159
|
|
97
|
-
Copyright (c)
|
160
|
+
Copyright (c) 2010
|
98
161
|
|
99
162
|
Permission is hereby granted, free of charge, to any person obtaining
|
100
163
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
|
|
5
5
|
require 'spec/rake/spectask'
|
6
6
|
|
7
7
|
GEM = "inploy"
|
8
|
-
GEM_VERSION = "1.
|
8
|
+
GEM_VERSION = "1.6.0"
|
9
9
|
SUMMARY = "Rails deployment made easy"
|
10
10
|
AUTHOR = "Diego Carrion"
|
11
11
|
EMAIL = "dc.rec1@gmail.com"
|
@@ -16,8 +16,8 @@ spec = Gem::Specification.new do |s|
|
|
16
16
|
s.version = GEM_VERSION
|
17
17
|
s.platform = Gem::Platform::RUBY
|
18
18
|
s.summary = SUMMARY
|
19
|
-
s.
|
20
|
-
s.
|
19
|
+
s.files = FileList['lib/**/*','bin/*', '[A-Z]*'].to_a
|
20
|
+
s.executables << "inploy"
|
21
21
|
|
22
22
|
s.author = AUTHOR
|
23
23
|
s.email = EMAIL
|
data/bin/inploy
ADDED
data/lib/inploy/cli.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Inploy
|
2
|
+
class CLI
|
3
|
+
def self.execute(params)
|
4
|
+
deploy = Deploy.new
|
5
|
+
case params.size
|
6
|
+
when 0
|
7
|
+
deploy.remote_update
|
8
|
+
when 1
|
9
|
+
deploy.send "remote_#{params.first}"
|
10
|
+
when 2
|
11
|
+
deploy.remote_install :from => params.last.sub("from=", "")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/inploy/deploy.rb
CHANGED
@@ -2,15 +2,18 @@ module Inploy
|
|
2
2
|
class Deploy
|
3
3
|
include Helper
|
4
4
|
include DSL
|
5
|
+
|
5
6
|
attr_accessor :repository, :user, :application, :hosts, :path, :ssh_opts, :branch, :environment,
|
6
|
-
:port, :skip_steps, :cache_dirs
|
7
|
+
:port, :skip_steps, :cache_dirs, :sudo
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
self.server = :passenger
|
10
|
-
|
11
|
+
@cache_dirs = %w(public/cache)
|
11
12
|
@branch = 'master'
|
12
13
|
@environment = 'production'
|
13
|
-
@
|
14
|
+
@user = "deploy"
|
15
|
+
@path = "/var/local/apps"
|
16
|
+
configure
|
14
17
|
end
|
15
18
|
|
16
19
|
def template=(template)
|
@@ -21,8 +24,14 @@ module Inploy
|
|
21
24
|
load_module "servers/#{server}"
|
22
25
|
end
|
23
26
|
|
24
|
-
def
|
25
|
-
|
27
|
+
def configure
|
28
|
+
if file = configuration_file
|
29
|
+
deploy = self
|
30
|
+
eval file.read
|
31
|
+
local_variables.each do |variable|
|
32
|
+
send "#{variable}=", eval(variable) rescue nil
|
33
|
+
end
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
37
|
def remote_install(opts)
|
data/lib/inploy/dsl.rb
CHANGED
@@ -29,13 +29,17 @@ module Inploy
|
|
29
29
|
run "ruby #{file} #{opts[:params]}" if File.exists?(file)
|
30
30
|
end
|
31
31
|
|
32
|
+
def sudo_if_should
|
33
|
+
@sudo ? 'sudo ' : ''
|
34
|
+
end
|
35
|
+
|
32
36
|
def run(command, disable_sudo = false)
|
33
37
|
log command
|
34
38
|
|
35
39
|
if disable_sudo
|
36
40
|
Kernel.system command
|
37
41
|
else
|
38
|
-
Kernel.system "#{
|
42
|
+
Kernel.system "#{sudo_if_should}#{command}"
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
data/lib/inploy/helper.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Inploy
|
2
2
|
module Templates
|
3
3
|
module Locaweb
|
4
|
+
def self.extended(base)
|
5
|
+
base.path = nil
|
6
|
+
end
|
7
|
+
|
4
8
|
def remote_setup
|
5
9
|
run "rm -Rf #{tmp_path} && git clone . #{tmp_path} && tar czf - #{tmp_path} | ssh #{user}@#{host} 'tar xzfv - -C ~/ && mv ~#{tmp_path} #{path}/ && cd #{application_path} && rake inploy:local:setup'"
|
6
10
|
end
|
data/lib/tasks/inploy.rake
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
|
2
2
|
require 'inploy'
|
3
3
|
|
4
|
-
|
5
|
-
@deploy ||= Inploy::Deploy.new
|
6
|
-
end
|
7
|
-
|
8
|
-
begin
|
9
|
-
require "config/deploy.rb"
|
10
|
-
rescue Exception
|
11
|
-
end
|
12
|
-
|
4
|
+
deploy = Inploy::Deploy.new
|
13
5
|
|
14
6
|
deploy.environment = ENV['environment'] || deploy.environment
|
15
7
|
deploy.skip_steps = ENV['skip_steps'].split(',') unless ENV['skip_steps'].nil?
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
7
|
+
- 6
|
8
8
|
- 0
|
9
|
-
version: 1.
|
9
|
+
version: 1.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Diego Carrion
|
@@ -14,19 +14,20 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-17 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description:
|
22
22
|
email: dc.rec1@gmail.com
|
23
|
-
executables:
|
24
|
-
|
23
|
+
executables:
|
24
|
+
- inploy
|
25
25
|
extensions: []
|
26
26
|
|
27
27
|
extra_rdoc_files: []
|
28
28
|
|
29
29
|
files:
|
30
|
+
- lib/inploy/cli.rb
|
30
31
|
- lib/inploy/deploy.rb
|
31
32
|
- lib/inploy/dsl.rb
|
32
33
|
- lib/inploy/helper.rb
|
@@ -38,6 +39,7 @@ files:
|
|
38
39
|
- lib/inploy/templates/rails3.rb
|
39
40
|
- lib/inploy.rb
|
40
41
|
- lib/tasks/inploy.rake
|
42
|
+
- bin/inploy
|
41
43
|
- Rakefile
|
42
44
|
- README.textile
|
43
45
|
has_rdoc: true
|