cmdeploy 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cmdeploy +46 -42
- data/lib/cmdeploy/recipes/assets.rb +10 -12
- data/lib/cmdeploy/recipes/base.rb +3 -10
- data/lib/cmdeploy/recipes/bundler.rb +12 -14
- data/lib/cmdeploy/recipes/nginx.rb +18 -21
- data/lib/cmdeploy/recipes/password_file.rb +1 -2
- data/lib/cmdeploy/recipes/revision_history.rb +11 -13
- data/lib/cmdeploy/recipes/templates/nginx_unicorn.erb +2 -2
- data/lib/cmdeploy/recipes/unicorn.rb +19 -21
- data/lib/cmdeploy/recipes/variables.rb +6 -8
- data/lib/cmdeploy/version.rb +1 -1
- metadata +2 -2
data/bin/cmdeploy
CHANGED
@@ -3,59 +3,63 @@
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'erb'
|
5
5
|
|
6
|
-
|
7
|
-
erb = File.read("#{File.dirname(__FILE__)}/../lib/cmdeploy/recipes/templates/#{from}")
|
8
|
-
File.open(to,"w") do |output|
|
9
|
-
output.write(ERB.new(erb).result(binding))
|
10
|
-
end
|
11
|
-
end
|
6
|
+
module CMDeploy
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
else
|
18
|
-
force = false
|
19
|
-
application = nil
|
20
|
-
|
21
|
-
ARGV.each do |arg|
|
22
|
-
case arg
|
23
|
-
when /-f/ then
|
24
|
-
force = true
|
25
|
-
else
|
26
|
-
application = application || arg
|
8
|
+
def self.template(application,from,to)
|
9
|
+
erb = File.read("#{File.dirname(__FILE__)}/../lib/cmdeploy/recipes/templates/#{from}")
|
10
|
+
File.open(to,"w") do |output|
|
11
|
+
output.write(ERB.new(erb).result(binding))
|
27
12
|
end
|
28
13
|
end
|
29
14
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
15
|
+
if ARGV.size == 0
|
16
|
+
# no arguments provided, show usage
|
17
|
+
puts "Usage of #{File.basename(__FILE__)}: bundle exec cmdeploy [-f] APPNAME"
|
18
|
+
puts " -f => force to overwrite existing files"
|
19
|
+
else
|
20
|
+
force = false
|
21
|
+
application = nil
|
22
|
+
|
23
|
+
ARGV.each do |arg|
|
24
|
+
case arg
|
25
|
+
when /-f/ then
|
26
|
+
force = true
|
27
|
+
else
|
28
|
+
application = application || arg
|
29
|
+
end
|
37
30
|
end
|
38
|
-
end
|
39
31
|
|
40
|
-
|
41
|
-
|
42
|
-
|
32
|
+
# checking where we are...
|
33
|
+
puts "Installing templates #{"[force mode] " if force}for application [#{application}]..."
|
34
|
+
puts "Checking actual folder..."
|
35
|
+
%w(app app/controllers config).each do |folder|
|
36
|
+
unless File.exists?(folder) && File.directory?(folder)
|
37
|
+
puts "=> Could not find folder [#{folder}]. You need to be in a Ruby On Rails root folder"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
end
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
list = []
|
43
|
+
list << ["deploy_rb.erb","config/deploy.rb"]
|
44
|
+
list << ["unicorn_rb.erb","config/unicorn.rb"]
|
47
45
|
|
48
|
-
|
46
|
+
list.each do |item|
|
47
|
+
from = item[0]
|
48
|
+
to = item[1]
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
puts "Processing [#{to}]..."
|
51
|
+
|
52
|
+
if File.exists?(to)
|
53
|
+
if force
|
54
|
+
puts "overwrite existing file"
|
55
|
+
else
|
56
|
+
puts "=> File [#{to}] exists. Please delete or use -f to overwrite."
|
57
|
+
exit 1
|
58
|
+
end
|
56
59
|
end
|
60
|
+
CMDeploy.template(application,from,to)
|
57
61
|
end
|
58
|
-
|
62
|
+
|
59
63
|
end
|
60
64
|
|
61
65
|
end
|
@@ -1,17 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Capistrano.configuration(:must_exist)
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
5
4
|
|
6
|
-
|
5
|
+
configuration.load do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
7
|
+
namespace :deploy do
|
8
|
+
namespace :assets do
|
9
|
+
desc "cmdeploy: Assets precompilation"
|
10
|
+
task :precompile do
|
11
|
+
run "cd #{release_path} && #{rake} RAILS_RELATIVE_URL_ROOT=#{app_relative_root_url} RAILS_ENV=#{stage} RAILS_GROUPS=assets assets:precompile"
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
17
|
-
end
|
15
|
+
end
|
@@ -1,11 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
end
|
5
|
-
|
6
|
-
def template(from, to)
|
7
|
-
erb = File.read("#{File.dirname(__FILE__)}/templates/#{from}")
|
8
|
-
put ERB.new(erb).result(binding), to
|
9
|
-
end
|
10
|
-
|
1
|
+
def cmdeploy_template(from, to)
|
2
|
+
erb = File.read("#{File.dirname(__FILE__)}/templates/#{from}")
|
3
|
+
put ERB.new(erb).result(binding), to
|
11
4
|
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Capistrano.configuration(:must_exist)
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
5
4
|
|
6
|
-
|
5
|
+
configuration.load do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
desc "cmdeploy: check and install gems via bundler"
|
11
|
-
task :bundle_setup, roles: :app do
|
12
|
-
run ". ~/.bashrc && cd #{release_path} && (bundle check || bundle install --without development) && bundle install --binstubs"
|
13
|
-
end
|
14
|
-
after "deploy:assets:symlink", "deploy:bundle_setup"
|
7
|
+
namespace :deploy do
|
15
8
|
|
9
|
+
desc "cmdeploy: check and install gems via bundler"
|
10
|
+
task :bundle_setup, roles: :app do
|
11
|
+
run ". ~/.bashrc && cd #{release_path} && (bundle check || bundle install --without development) && bundle install --binstubs"
|
16
12
|
end
|
17
|
-
|
13
|
+
after "deploy:assets:symlink", "deploy:bundle_setup"
|
18
14
|
|
19
15
|
end
|
20
|
-
|
16
|
+
|
17
|
+
|
18
|
+
end
|
@@ -1,30 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Capistrano.configuration(:must_exist)
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
5
4
|
|
6
|
-
|
5
|
+
configuration.load do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
namespace :nginx do
|
8
|
+
desc "cmdeploy: setup nginx configuration for this application"
|
9
|
+
task :setup, roles: :web do
|
10
|
+
cmdeploy_template("nginx_unicorn.erb","/tmp/nginx_unicorn")
|
11
|
+
run "mv /tmp/nginx_unicorn #{nginx_conf_folder}/#{application}.conf"
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
cmdeploy_template("nginx_unicorn_upstream.erb","/tmp/nginx_unicorn_upstream")
|
14
|
+
run "mv /tmp/nginx_unicorn_upstream #{nginx_conf_folder}/upstream/#{application}.conf"
|
15
|
+
end
|
16
|
+
after "deploy:setup", "nginx:setup"
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
18
|
+
%w[start stop restart status reload configtest].each do |command|
|
19
|
+
desc "cmdeploy: #{command} nginx"
|
20
|
+
task command, roles: :web do
|
21
|
+
run "#{sudo} /sbin/service nginx #{command}"
|
24
22
|
end
|
25
|
-
|
26
23
|
end
|
27
24
|
|
28
|
-
|
29
25
|
end
|
26
|
+
|
30
27
|
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Capistrano.configuration(:must_exist)
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
5
4
|
|
6
|
-
|
5
|
+
configuration.load do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
desc "cmdeploy: fetch revision history"
|
11
|
-
task :fetch_revision_history, roles: :app do
|
12
|
-
run "cd #{release_path} && svn log --xml #{release_path} > revision.xml"
|
13
|
-
end
|
7
|
+
namespace :deploy do
|
14
8
|
|
9
|
+
desc "cmdeploy: fetch revision history"
|
10
|
+
task :fetch_revision_history, roles: :app do
|
11
|
+
run "cd #{release_path} && svn log --xml #{release_path} > revision.xml"
|
15
12
|
end
|
16
|
-
after "deploy:assets:precompile", "deploy:fetch_revision_history"
|
17
13
|
|
18
14
|
end
|
19
|
-
|
15
|
+
after "deploy:assets:precompile", "deploy:fetch_revision_history"
|
16
|
+
|
17
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# deliver static assets as gzip files
|
2
|
-
location ~
|
2
|
+
location ~ ^<%= [nil,'','/'].include?(app_relative_root_url) ? "/" : "#{app_relative_root_url}/" %>assets/ {
|
3
3
|
root /CHBS/apps/apps/<%= application %>/current/public;
|
4
4
|
gzip_static on; # to serve pre-gzipped version
|
5
5
|
expires max;
|
@@ -7,7 +7,7 @@ location ~ ^/<%= application %>/assets/ {
|
|
7
7
|
}
|
8
8
|
|
9
9
|
# pass request to rails app
|
10
|
-
location ~
|
10
|
+
location <%= [nil,'','/'].include?(app_relative_root_url) ? "/" : "~ ^#{app_relative_root_url}" %> {
|
11
11
|
root /CHBS/apps/apps/<%= application %>/current/public;
|
12
12
|
|
13
13
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
@@ -1,29 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Capistrano.configuration(:must_exist)
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
5
4
|
|
6
|
-
|
5
|
+
configuration.load do
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
namespace :unicorn do
|
8
|
+
desc "cmdeploy: create unicorn startup script"
|
9
|
+
task :setup, roles: :app do
|
10
|
+
run "mkdir -p #{unicorn_conf_folder}"
|
11
|
+
cmdeploy_template("unicorn_conf.erb","/tmp/unicorn_conf")
|
12
|
+
run "mv /tmp/unicorn_conf #{unicorn_conf_folder}/#{application}.conf"
|
13
|
+
end
|
14
|
+
after "deploy:setup", "unicorn:setup"
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
16
|
+
%w[start stop restart reload upgrade status rotate].each do |command|
|
17
|
+
desc "cmdeploy: #{command} unicorn"
|
18
|
+
task command, roles: :app do
|
19
|
+
run ". ~/.bashrc && uc #{command} ~/etc/unicorn/#{application}.conf"
|
22
20
|
end
|
23
|
-
after "deploy:restart", "unicorn:reload"
|
24
|
-
|
25
21
|
end
|
26
|
-
|
22
|
+
after "deploy:restart", "unicorn:reload"
|
27
23
|
|
28
24
|
end
|
25
|
+
|
26
|
+
|
29
27
|
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Capistrano.configuration(:must_exist)
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
5
4
|
|
6
|
-
|
5
|
+
configuration.load do
|
7
6
|
|
8
7
|
# cm specific settings
|
9
8
|
set :stage, 'test'
|
@@ -20,7 +19,7 @@ module CMDeploy
|
|
20
19
|
# scm
|
21
20
|
set :scm, :subversion
|
22
21
|
set :repository, "http://svn.nibr.novartis.intra/svn/SDM/cm/module/#{application}/branches/master/src/rails"
|
23
|
-
|
22
|
+
|
24
23
|
# sudo
|
25
24
|
set :use_sudo, false
|
26
25
|
|
@@ -34,5 +33,4 @@ module CMDeploy
|
|
34
33
|
# per default only 5 release will be kept
|
35
34
|
after "deploy:assets:precompile", "deploy:cleanup"
|
36
35
|
|
37
|
-
|
38
|
-
end
|
36
|
+
end
|
data/lib/cmdeploy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmdeploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: CM specific deployment recipes
|
15
15
|
email:
|