rebuy_deployment 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ def prompt_if_unset(name, default = '')
2
+ unless exists? name
3
+ set name do
4
+ prompt = "Enter #{name}: "
5
+ Capistrano::CLI.ui.ask(prompt) do |q|
6
+ q.overwrite = false
7
+ q.validate = /.+/
8
+ q.default = default unless default.empty?
9
+ q.responses[:not_valid] = prompt
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ set :stages, %w(production sandbox)
16
+ set :default_stage, 'sandbox'
17
+ set :stage_dir, './deployment/multistage'
18
+ require 'capistrano/ext/multistage'
19
+
20
+ prompt_if_unset :branch, 'master'
21
+ ssh_options[:user] = 'deployment'
22
+ default_run_options[:pty] = true
23
+
24
+ set :application, 'REPLACE_ME'
25
+ set :scm, :git
26
+ set :repository, 'REPLACE_ME'
27
+ set :deploy_via, :copy
28
+ set :copy_dir, Dir.tmpdir
29
+ set :copy_cache, true
30
+
31
+ set(:copy_remote_dir) { "#{deploy_to}" }
32
+ set(:build_script) { "rake -f deployment/rakefile default[#{stage},#{release_name},#{fqdn}]" }
33
+
34
+ set :copy_exclude, [".git/*", ".git", "deployment/*.rb", "Capfile"]
35
+
36
+ namespace :deploy do
37
+ task :symlink_shared do
38
+ run "#{try_sudo} rm -rf #{release_path}/#{shared_dir}"
39
+ run "ln -s #{shared_path} #{release_path}/#{shared_dir}"
40
+ end
41
+
42
+ task :change_owner do
43
+ run "#{try_sudo} chown -R nobody:nobody #{release_path}"
44
+ run "#{try_sudo} chmod -R ug=rw-x+X,o= #{release_path}"
45
+ end
46
+
47
+ task :prepare_directory_structure do
48
+ run "#{try_sudo} mkdir -p #{shared_path}/logs"
49
+ run "#{try_sudo} chown -R nobody:nobody #{deploy_to}"
50
+ run "#{try_sudo} chmod -R ug=rw-x+X,o= #{deploy_to}"
51
+ end
52
+
53
+ task :restart, :roles => :app do
54
+ run "#{try_sudo} /usr/bin/svc -d /service/#{application}"
55
+ run "#{try_sudo} /usr/bin/svc -u /service/#{application}"
56
+ end
57
+ end
58
+
59
+ after 'deploy:finalize_update', 'deploy:symlink_shared'
60
+ after 'deploy:finalize_update', 'deploy:change_owner'
61
+ after 'deploy:symlink', 'deploy:restart'
62
+ after 'deploy:setup', 'deploy:prepare_directory_structure'
@@ -0,0 +1,26 @@
1
+ task :default, [:target, :version, :fqdn] => [:write_env_file, :copy_ini]
2
+
3
+ def show_desc (task)
4
+ puts (task.full_comment ? task.full_comment : task.name) + " ..."
5
+ end
6
+
7
+ desc "creating environment.inc.php"
8
+ task :write_env_file, [:target, :version, :fqdn] do |task, args|
9
+ show_desc task
10
+
11
+ File.delete("environment.inc.php.dist")
12
+ File.open "environment.inc.php", "w+" do |file|
13
+ file.puts "<?php"
14
+ file.puts "ini_set('error_log', 'shared/logs/error.log');"
15
+ file.puts "define('APPLICATION_ENV', '#{args[:target]}');"
16
+ file.puts "define('APPLICATION_VERSION', '#{args[:version]}');"
17
+ file.puts "define('APPLICATION_FQDN', '#{args[:fqdn]}');"
18
+ end
19
+ end
20
+
21
+ desc "creating Application.ini ..."
22
+ task :copy_ini do |task|
23
+ show_desc task
24
+
25
+ File.rename("Configs/Application.ini.dist", "Configs/Application.ini")
26
+ end
@@ -0,0 +1,14 @@
1
+ class Rebuy_Deployment
2
+ attr_reader :path
3
+ def initialize
4
+ @path = File.expand_path File.dirname(__FILE__)
5
+ end
6
+
7
+ def get_receipt_path
8
+ @path + "/rebuy_deployment/deploy.rb"
9
+ end
10
+
11
+ def get_rakefile_path
12
+ @path + "/rebuy_deployment/rakefile"
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rebuy_deployment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mike Roetgers
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: &17592560 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *17592560
25
+ - !ruby/object:Gem::Dependency
26
+ name: capistrano-ext
27
+ requirement: &17591660 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *17591660
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &17591120 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *17591120
47
+ description: This gem offers deployment for all rebuy.de projects
48
+ email:
49
+ - m.roetgers@rebuy.de
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/rebuy_deployment.rb
55
+ - lib/rebuy_deployment/deploy.rb
56
+ - lib/rebuy_deployment/rakefile
57
+ homepage:
58
+ licenses: []
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.11
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Capistrano deployment for rebuy.de projects
81
+ test_files: []