inploy 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +79 -0
- data/Rakefile +55 -0
- data/lib/inploy.rb +2 -0
- data/lib/inploy/deploy.rb +43 -0
- data/lib/inploy/helper.rb +69 -0
- data/lib/inploy/locaweb.rb +31 -0
- data/lib/tasks/inploy.rake +37 -0
- metadata +61 -0
data/README.textile
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
h2. ABOUT:
|
2
|
+
|
3
|
+
Inploy is a Rails plugin to deploy applications in a easier way. You can use Inploy from a remote machine or from the local machine, too. It's integrated with Git, Rake and intended to do most of the common work, so you don't need to.
|
4
|
+
|
5
|
+
Actually, Inploy has four rake tasks:
|
6
|
+
|
7
|
+
* inploy:remote:setup
|
8
|
+
|
9
|
+
- connects to a list of servers
|
10
|
+
- clones a git repository
|
11
|
+
- runs inploy:local:setup
|
12
|
+
|
13
|
+
* inploy:remote:update
|
14
|
+
|
15
|
+
- connects to a list of servers
|
16
|
+
- runs inploy:local:update
|
17
|
+
|
18
|
+
* inploy:local:setup
|
19
|
+
|
20
|
+
- copies config/*.sample files to config/*
|
21
|
+
- creates directory tmp/pids
|
22
|
+
- executes init.sh file case it exists
|
23
|
+
- installs gems
|
24
|
+
- migrates the database for the production environment
|
25
|
+
- cleans the cache in public/cache
|
26
|
+
- parses less files if more:parse tasks exists
|
27
|
+
- package the assets if asset:packager:build_all task exists
|
28
|
+
- touch tmp/restart.txt
|
29
|
+
|
30
|
+
* inploy:local:update
|
31
|
+
|
32
|
+
- pulls the repository
|
33
|
+
- installs gems
|
34
|
+
- migrates the database for the production environment
|
35
|
+
- cleans the cache in public/cache
|
36
|
+
- parses less files if more:parse tasks exists
|
37
|
+
- package the assets if asset:packager:build_all task exists
|
38
|
+
- touch tmp/restart.txt
|
39
|
+
|
40
|
+
h2. INSTALLATION:
|
41
|
+
|
42
|
+
<pre><code>script/plugin install git://github.com/dcrec1/inploy.git</code></pre>
|
43
|
+
|
44
|
+
h2. CONFIGURATION
|
45
|
+
|
46
|
+
Create a config/deploy.rb file and configure it something like this:
|
47
|
+
|
48
|
+
<pre><code>deploy.application = "signal"
|
49
|
+
deploy.repository = 'git://github.com/dcrec1/signal.git'
|
50
|
+
deploy.user = 'dcrec1'
|
51
|
+
deploy.hosts = ['hooters', 'geni']
|
52
|
+
deploy.path = '/opt'</code></pre>
|
53
|
+
|
54
|
+
Path and user are optional, default values are /opt and root.
|
55
|
+
|
56
|
+
h2. LICENSE:
|
57
|
+
|
58
|
+
(The MIT License)
|
59
|
+
|
60
|
+
Copyright (c) 2009
|
61
|
+
|
62
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
63
|
+
a copy of this software and associated documentation files (the
|
64
|
+
'Software'), to deal in the Software without restriction, including
|
65
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
66
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
67
|
+
permit persons to whom the Software is furnished to do so, subject to
|
68
|
+
the following conditions:
|
69
|
+
|
70
|
+
The above copyright notice and this permission notice shall be
|
71
|
+
included in all copies or substantial portions of the Software.
|
72
|
+
|
73
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
74
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
75
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
76
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
77
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
78
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
79
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/specification'
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
GEM = "inploy"
|
8
|
+
GEM_VERSION = "1.0.0"
|
9
|
+
SUMMARY = "Rails deployment made easy"
|
10
|
+
AUTHOR = "Diego Carrion"
|
11
|
+
EMAIL = "dc.rec1@gmail.com"
|
12
|
+
HOMEPAGE = "http://www.diegocarrion.com"
|
13
|
+
|
14
|
+
spec = Gem::Specification.new do |s|
|
15
|
+
s.name = GEM
|
16
|
+
s.version = GEM_VERSION
|
17
|
+
s.platform = Gem::Platform::RUBY
|
18
|
+
s.summary = SUMMARY
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.files = FileList['lib/**/*', '[A-Z]*'].to_a
|
21
|
+
|
22
|
+
s.author = AUTHOR
|
23
|
+
s.email = EMAIL
|
24
|
+
s.homepage = HOMEPAGE
|
25
|
+
|
26
|
+
s.rubyforge_project = GEM # GitHub bug, gem isn't being build when this miss
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new do |t|
|
30
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
31
|
+
t.spec_opts = %w(-fs --color)
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
35
|
+
pkg.gem_spec = spec
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Install the gem locally"
|
39
|
+
task :install => [:package] do
|
40
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Create a gemspec file"
|
44
|
+
task :make_spec do
|
45
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
46
|
+
file.puts spec.to_ruby
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Run all examples with RCov"
|
51
|
+
Spec::Rake::SpecTask.new('rcov') do |t|
|
52
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
53
|
+
t.rcov = true
|
54
|
+
t.rcov_opts = ['--no-html', '-T', '--exclude', 'spec']
|
55
|
+
end
|
data/lib/inploy.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Inploy
|
2
|
+
class Deploy
|
3
|
+
include Helper
|
4
|
+
|
5
|
+
attr_accessor :repository, :user, :application, :hosts, :path
|
6
|
+
|
7
|
+
def template=(template)
|
8
|
+
require "inploy/#{template}"
|
9
|
+
extend eval(camelize(template))
|
10
|
+
end
|
11
|
+
|
12
|
+
def remote_setup
|
13
|
+
remote_run "cd #{path} && git clone --depth 1 #{repository} #{application} && cd #{application} && rake inploy:local:setup"
|
14
|
+
end
|
15
|
+
|
16
|
+
def local_setup
|
17
|
+
copy_sample_files
|
18
|
+
create_folders 'tmp/pids', 'db'
|
19
|
+
run "./init.sh" if File.exists?("init.sh")
|
20
|
+
after_update_code
|
21
|
+
end
|
22
|
+
|
23
|
+
def remote_update
|
24
|
+
remote_run "cd #{application_path} && rake inploy:local:update"
|
25
|
+
end
|
26
|
+
|
27
|
+
def local_update
|
28
|
+
run "git pull origin master"
|
29
|
+
after_update_code
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def after_update_code
|
35
|
+
install_gems
|
36
|
+
migrate_database
|
37
|
+
run "rm -R -f public/cache"
|
38
|
+
rake_if_included "more:parse"
|
39
|
+
rake_if_included "asset:packager:build_all"
|
40
|
+
run "touch tmp/restart.txt"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Inploy
|
2
|
+
module Helper
|
3
|
+
def create_folders(*folders)
|
4
|
+
folders.each { |folder| create_folder folder }
|
5
|
+
end
|
6
|
+
|
7
|
+
def create_folder(path)
|
8
|
+
run "mkdir -p #{path}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def host
|
12
|
+
hosts.first
|
13
|
+
end
|
14
|
+
|
15
|
+
def camelize(string)
|
16
|
+
string.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
17
|
+
end
|
18
|
+
|
19
|
+
def application_path
|
20
|
+
"#{path}/#{application}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_sample_files
|
24
|
+
Dir.glob("config/*.sample").each do |file|
|
25
|
+
secure_copy file, file.gsub(".sample", '')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def secure_copy(src, dest)
|
30
|
+
log "mv #{src} #{dest}"
|
31
|
+
FileUtils.cp src, dest unless File.exists?(dest)
|
32
|
+
end
|
33
|
+
|
34
|
+
def migrate_database
|
35
|
+
rake "db:migrate RAILS_ENV=production"
|
36
|
+
end
|
37
|
+
|
38
|
+
def tasks
|
39
|
+
`rake -T`
|
40
|
+
end
|
41
|
+
|
42
|
+
def rake_if_included(command)
|
43
|
+
rake command if tasks.include?("rake #{command}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def rake(command)
|
47
|
+
run "rake #{command}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def remote_run(command)
|
51
|
+
hosts.each do |host|
|
52
|
+
run "ssh #{user}@#{host} '#{command}'"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def run(command)
|
57
|
+
log command
|
58
|
+
Kernel.system command
|
59
|
+
end
|
60
|
+
|
61
|
+
def log(command)
|
62
|
+
puts "Inploy => #{command}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def install_gems
|
66
|
+
rake "gems:install"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Inploy
|
2
|
+
module Locaweb
|
3
|
+
def remote_setup
|
4
|
+
run "rm -Rf #{tmp_path} && git clone --depth 1 . #{tmp_path} && tar czf - #{tmp_path} | ssh #{user}@#{host} 'tar xzfv - -C ~/ && mv ~#{tmp_path} #{path}/ && cd #{application_path} && rake inploy:local:setup'"
|
5
|
+
end
|
6
|
+
|
7
|
+
def remote_update
|
8
|
+
run "git push ssh://[#{user}@#{host}]#{application_path} master"
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def local_setup
|
13
|
+
super
|
14
|
+
run "ln -s #{application_path}/public /home/#{user}/public_html/#{application}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def local_update
|
18
|
+
after_update_code
|
19
|
+
end
|
20
|
+
|
21
|
+
def path
|
22
|
+
@path ||= "/home/#{user}/rails_app"
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def tmp_path
|
28
|
+
"/tmp/#{application}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
|
2
|
+
require 'inploy'
|
3
|
+
|
4
|
+
def deploy
|
5
|
+
@deploy ||= Inploy::Deploy.new
|
6
|
+
end
|
7
|
+
|
8
|
+
begin
|
9
|
+
require "config/deploy.rb"
|
10
|
+
rescue Exception
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :inploy do
|
14
|
+
namespace :local do
|
15
|
+
desc "Local Setup"
|
16
|
+
task :setup do
|
17
|
+
deploy.local_setup
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Local Update"
|
21
|
+
task :update do
|
22
|
+
deploy.local_update
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :remote do
|
27
|
+
desc "Remote Setup"
|
28
|
+
task :setup do
|
29
|
+
deploy.remote_setup
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Remote Update"
|
33
|
+
task :update do
|
34
|
+
deploy.remote_update
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diego Carrion
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-20 00:00:00 -02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: dc.rec1@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/tasks/inploy.rake
|
26
|
+
- lib/inploy/locaweb.rb
|
27
|
+
- lib/inploy/deploy.rb
|
28
|
+
- lib/inploy/helper.rb
|
29
|
+
- lib/inploy.rb
|
30
|
+
- README.textile
|
31
|
+
- Rakefile
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://www.diegocarrion.com
|
34
|
+
licenses: []
|
35
|
+
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project: inploy
|
56
|
+
rubygems_version: 1.3.5
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Rails deployment made easy
|
60
|
+
test_files: []
|
61
|
+
|