square-eycap 0.4.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,154 @@
1
+ == 0.4.12 / 2009-06-26
2
+ * removed condition for dbhost that was useless and tested db:clone_prod_to_staging
3
+
4
+ == 0.4.11 / 2009-06-25
5
+ * changed nginx start and restart to give output to cap
6
+ * fixed db:clone_to_local task
7
+
8
+ == 0.4.10 / 2009-06-24
9
+ * using nohup on nginx start and restart
10
+
11
+ == 0.4.9 / 2009-06-22
12
+ * added nginx reload, upgrade and configtest - thanks Randy (ydnar)
13
+
14
+ == 0.4.8 / there is no 0.4.8, just like there is no spoon.
15
+
16
+ == 0.4.7 / 2009-05-12
17
+ * fixed bug in clone_prod_to_staging and clone_to_local db tasks for postgres
18
+ where the regex matching the password prompt for the restore was wrong
19
+
20
+ == 0.4.6 / 2009-03-24
21
+ * fixed bug to restore clone_prod_to_staging using the compressed file
22
+
23
+ == 0.4.5 / 2009-03-03
24
+ * happy square root day!
25
+ * added the staging restore to db:clone_prod_to_staging
26
+
27
+ == 0.4.4 / 2009-03-03
28
+ * happy square root day!
29
+ * fixed the *correct* database.rb file for the db:clone_prod_to_staging
30
+
31
+ == 0.4.3 / 2009-02-11
32
+ * updated db:dump command for Engine Yard Solo offering, fixing a bug where
33
+ the dbname wasn't included.
34
+
35
+ == 0.4.2 / 2009-02-11
36
+ * added condition to determine if the db:dump command is run against our
37
+ traditional offering or the new cloud offering
38
+ * fixed bug where if a production db host name doesn't have a -master at the
39
+ end it won't run the db:clone_prod_to_staging correctly
40
+
41
+ == 0.4.1 / 2009-01-09
42
+ * fixed bug for passenger:restart
43
+
44
+ == 0.4.0 / 2009-01-09
45
+ * add passenger:restart task
46
+ * add apache stop, start, restart and reload tasks
47
+ * Don't display database passwords in the logs, output, etc. use stdin instead
48
+
49
+ == 0.3.11 / 2008-11-09
50
+ * filtered_remote_cache uses svn switch
51
+
52
+ == 0.3.9 / 2008-09-29
53
+ * add reindex task for /engineyard/bin/acts_as_sphinx_searchd
54
+ * add reindex and configure task for /engineyard/bin/ultrasphinx_searchd
55
+ * add reindex and configure task for /engineyard/bin/thinking_sphinx_searchd
56
+
57
+ == 0.3.8 / 2008-09-22
58
+ * add PostgreSQL support to the database.rb recipe.
59
+
60
+ == 0.3.7 / 2008-08-23
61
+ * fix from customer for filtered_remote_cache to just use plain grep.
62
+
63
+ == 0.3.6 / 2008-07-17
64
+ * features updated VERSION
65
+
66
+ == 0.3.5 / 2008-07-17
67
+ * filtered_remote_cache uses cached checkout's repository root for comparison for speedier tagged/branched deploys
68
+
69
+ == 0.3.4 / 2008-06-17
70
+ * rake install_gem_no_doc for faster install
71
+ * set role to db for backup_name task
72
+ * add migration support for merb
73
+
74
+ == 0.3.3 / 2008-05-07
75
+ * add ey_logger to log deploys to server
76
+
77
+ == 0.3.2 / 2008-04-29
78
+ * adding db:clone_to_local task to take a dump on the slice, fetch it, and load it into your dev db on your workstation
79
+ * only clone from replica database
80
+ * remove call to variable in task desc
81
+ * fix ferret symlinking
82
+ * gemspec for github
83
+
84
+ == 0.3.1 / 2008-03-17
85
+ * Make the custom maintenance pages actually work!
86
+
87
+ == 0.3.0 / 2008-03-05
88
+ * Adding custom maintenance pages is now as easy as copying a custom html file to #{shared_path}/system/maintenance.html.custom
89
+
90
+ == 0.2.10 / 2008-03-02
91
+ * Symlink memcached.yml only on :memcached => true, except :no_release => true
92
+
93
+ == 0.2.9 / 2008-02-27
94
+ * Fix a bug with ultrasphinx:configure running on multiple hosts
95
+
96
+ == 0.2.8 / 2008-02-20
97
+ * Add tasks for solr starting,stopping, and log tailing.
98
+ * Add monit namespace and make appservers php/merb compatible
99
+ * Make ultrasphinx symlinking a little smarter
100
+ * Add tomcat tasks for spongecell
101
+
102
+ == 0.2.6 / 2008-02-14
103
+ * Make mongrel restarts only apply to mongrel slices
104
+
105
+ == 0.2.5 / 2008-02-11
106
+ * Added db cloning task
107
+
108
+ == 0.2.4 / 2008-02-06
109
+ * Symlink memcached.yml in on deploy if you enable the callback
110
+
111
+ == 0.2.3 / 2008-02-01
112
+ * Make log tailing environmentally aware. Also add tasks to tail mongrel logs
113
+
114
+ == 0.2.2 / 2008-01-25
115
+ * sphinx:configure ultrasphinx configuration task
116
+
117
+ == 0.2.1 / 2008-01-25
118
+ * override default deploy recipe start/stop tasks
119
+
120
+ == 0.2.0 / 2008-01-23
121
+ * sphinx:symlink ultrasphinx configuration directory
122
+
123
+ == 0.1.9 / 2008-01-21
124
+ * Correct memcached tasks.
125
+
126
+ == 0.1.8 / 2008-01-20
127
+ * Add memcached tasks
128
+
129
+ == 0.1.7 / 2008-01-19
130
+ * fix symlink_configs task
131
+
132
+ == 0.1.6 / 2008-01-19
133
+ * add restart tasks for backgroundrb
134
+
135
+ == 0.1.5 / 2008-01-18
136
+ * fixed bug in filtered_remote_cache that prevented a changed checkout URL from taking over the cache
137
+
138
+ == 0.1.4 / 2008-01-17
139
+ * added sphinx:[reindex|start|stop|restart] matches only app servers with :sphinx => true
140
+
141
+ == 0.1.3 / 2008-01-17
142
+ * filtered_remote_cache to removes the cached copy of the source URL changed
143
+
144
+ == 0.1.2 / 2008-01-15
145
+ * added filtered_remote_cache capistrano deployment strategy
146
+
147
+ == 0.1.1 / 2008-01-15
148
+ * removed database tasks until problem with 'defer' is solved
149
+
150
+ == 0.1.0 / 2008-01-14
151
+ * Bugfix for empty :application variable
152
+
153
+ == 0.0.1 / 2008-01-14
154
+ * Initial release
@@ -0,0 +1,28 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb
6
+ lib/capistrano/recipes/deploy/strategy/remote_cache.rb
7
+ lib/eycap.rb
8
+ lib/eycap/lib/ey_logger.rb
9
+ lib/eycap/lib/ey_logger_hooks.rb
10
+ lib/eycap/recipes.rb
11
+ lib/eycap/recipes/backgroundrb.rb
12
+ lib/eycap/recipes/database.rb
13
+ lib/eycap/recipes/deploy.rb
14
+ lib/eycap/recipes/ferret.rb
15
+ lib/eycap/recipes/juggernaut.rb
16
+ lib/eycap/recipes/memcached.rb
17
+ lib/eycap/recipes/mongrel.rb
18
+ lib/eycap/recipes/monit.rb
19
+ lib/eycap/recipes/nginx.rb
20
+ lib/eycap/recipes/slice.rb
21
+ lib/eycap/recipes/solr.rb
22
+ lib/eycap/recipes/sphinx.rb
23
+ lib/eycap/recipes/templates/maintenance.rhtml
24
+ lib/eycap/recipes/tomcat.rb
25
+ lib/eycap/recipes/passenger.rb
26
+ lib/eycap/recipes/apache.rb
27
+ test/test_eycap.rb
28
+ test/test_helper.rb
@@ -0,0 +1,65 @@
1
+ = eycap
2
+
3
+ == DESCRIPTION:
4
+
5
+ Engine Yard capistrano tasks for use specifically with Engine Yard slices. They include convenience methods for managed a database, mongrel, nginx or other services.
6
+
7
+ Also included is a deployment strategy, :filtered_remote_cache, which speeds up deployment like :remote_cache, but filters out .svn directory which are a security risk and write slowly to shared disks.
8
+
9
+ == REQUIREMENTS:
10
+
11
+ * capistrano (http://capify.org) > 2.0.0, but recommended with > 2.2.0
12
+
13
+ * NOTE: If you're using a git repository we recommend capistrano 2.5.3 and greater.
14
+
15
+ == INSTALL:
16
+
17
+ $ gem sources -a http://gems.github.com/ (you only need to do this once)
18
+ $ gem install engineyard-eycap
19
+
20
+ == SOURCE:
21
+
22
+ eycap's git repo is available on GitHub, which can be browsed at:
23
+
24
+ http://github.com/engineyard/eycap
25
+
26
+ and cloned from:
27
+
28
+ git://github.com/engineyard/eycap.git
29
+
30
+ == USAGE:
31
+
32
+ = Include in capistrano
33
+
34
+ In your deploy.rb, simply include this line at the top:
35
+
36
+ require 'eycap/recipes'
37
+
38
+ = Filtered remote cache
39
+
40
+ To use filtered_remote_cache, simply:
41
+
42
+ set :deploy_via, :filtered_remote_cache
43
+
44
+ == LICENSE:
45
+
46
+ Copyright (c) 2008 Engine Yard
47
+
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of this software and associated documentation files (the
50
+ "Software"), to deal in the Software without restriction, including
51
+ without limitation the rights to use, copy, modify, merge, publish,
52
+ distribute, sublicense, and/or sell copies of the Software, and to
53
+ permit persons to whom the Software is furnished to do so, subject to
54
+ the following conditions:
55
+
56
+ The above copyright notice and this permission notice shall be
57
+ included in all copies or substantial portions of the Software.
58
+
59
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
60
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
61
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
62
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
63
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
64
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
65
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+ require 'hoe'
3
+ require './lib/eycap'
4
+
5
+ Hoe.new('eycap', Eycap::VERSION) do |p|
6
+ p.author = 'Engine Yard'
7
+ p.email = 'tech@engineyard.com'
8
+ p.summary = 'Capistrano tasks for Engine Yard slices'
9
+ p.description = 'A bunch of useful recipes to help deployment to Engine Yard slices'
10
+ p.url = 'http://github.com/engineyard/eycap/tree/master'
11
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
12
+ p.extra_deps << ['capistrano', '>= 2.2.0']
13
+ end
14
+
15
+ desc "Open an irb session preloaded with this library"
16
+ task :console do
17
+ sh "irb -rubygems -r ./lib/eycap.rb"
18
+ end
19
+
20
+ task :coverage do
21
+ system("rm -fr coverage")
22
+ system("rcov test/test_*.rb")
23
+ system("open coverage/index.html")
24
+ end
25
+
26
+ desc "Upload site to Rubyforge"
27
+ task :site do
28
+ end
29
+
30
+ desc 'Install the package as a gem.'
31
+ task :install_gem_no_doc => [:clean, :package] do
32
+ sh "#{'sudo ' unless Hoe::WINDOZE}gem install --local --no-rdoc --no-ri pkg/*.gem"
33
+ end
@@ -0,0 +1,57 @@
1
+ require 'capistrano/recipes/deploy/scm/base'
2
+ require 'capistrano/recipes/deploy/strategy/remote'
3
+
4
+ module Capistrano
5
+ module Deploy
6
+ module SCM
7
+ class Subversion < Base
8
+ def switch(revision, checkout)
9
+ "cd #{checkout} && #{scm :switch, verbose, authentication, "-r#{revision}", repository}"
10
+ end
11
+ end
12
+ end
13
+
14
+ module Strategy
15
+
16
+ # Implements the deployment strategy that keeps a cached checkout of
17
+ # the source code on each remote server. Each deploy simply updates the
18
+ # cached checkout, and then filters a copy through tar to remove unwanted .svn directories,
19
+ # finally leaving a pristeen, export-like copy at the destination.
20
+ class FilteredRemoteCache < Remote
21
+ # Executes the SCM command for this strategy and writes the REVISION
22
+ # mark file to each host.
23
+ def deploy!
24
+ update_repository_cache
25
+ tar_copy_repository_cache
26
+ end
27
+
28
+ def check!
29
+ super.check do |d|
30
+ d.remote.writable(shared_path)
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def repository_cache
37
+ configuration[:repository_cache] || "/var/cache/engineyard/#{configuration[:application]}"
38
+ end
39
+
40
+ def update_repository_cache
41
+ logger.trace "checking if the cached copy repository root matches this deploy, then updating it"
42
+ command = "if [ -d #{repository_cache} ] && ! echo '#{configuration[:repository]}' | grep -q `svn info #{repository_cache} | grep 'Repository Root' | awk '{print $3}'`; then " +
43
+ "rm -rf #{repository_cache} && #{source.checkout(revision, repository_cache)}; " +
44
+ "elif [ -d #{repository_cache} ]; then #{source.switch(revision, repository_cache)}; " +
45
+ "else #{source.checkout(revision, repository_cache)}; fi"
46
+ scm_run(command)
47
+ end
48
+
49
+ def tar_copy_repository_cache
50
+ logger.trace "copying and filtering .svn via tar from cached version to #{configuration[:release_path]}"
51
+ run "mkdir #{configuration[:release_path]} && tar c --exclude=#{configuration[:filter_spec] || ".svn"} -C #{repository_cache} . | tar xC #{configuration[:release_path]} && #{mark}"
52
+ end
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ require 'capistrano/recipes/deploy/strategy/remote_cache'
2
+
3
+ module Capistrano
4
+ module Deploy
5
+ module Strategy
6
+ class UnsharedRemoteCache < RemoteCache
7
+ def check!
8
+ super.check do |d|
9
+ d.remote.writable(repository_cache)
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def repository_cache
16
+ configuration[:repository_cache]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Eycap
2
+ VERSION = '0.4.12'
3
+ end
@@ -0,0 +1,125 @@
1
+ require 'tmpdir'
2
+ require 'fileutils'
3
+ module Capistrano
4
+
5
+ class Logger
6
+
7
+ def ey_log(level, message, line_prefix = nil)
8
+ EYLogger.log(level, message, line_prefix) if EYLogger.setup?
9
+ log_without_ey_logging(level, message, line_prefix)
10
+ end
11
+
12
+ unless method_defined?(:log_without_ey_logging)
13
+ alias_method :log_without_ey_logging, :log
14
+ alias_method :log, :ey_log
15
+ end
16
+
17
+ def close
18
+ device.close if @needs_close
19
+ EYLogger.close if EYLogger.setup?
20
+ end
21
+ end
22
+
23
+ class EYLogger
24
+
25
+ # Sets up the EYLogger to beging capturing capistrano's logging. You should pass the capistrno configuration
26
+ # and the deploy type as a string. The deploy type is for reporting purposes only but must be included.
27
+ def self.setup(configuration, deploy_type, options = {})
28
+ @_configuration = configuration
29
+ @_deploy_type = deploy_type.gsub(/:/, "_")
30
+ @_log_path = options[:deploy_log_path] || Dir.tmpdir
31
+ @_log_path << "/" unless @_log_path =~ /\/$/
32
+ FileUtils.mkdir_p(@_log_path)
33
+ @_setup = true
34
+ @_success = true
35
+ end
36
+
37
+ def self.log(level, message, line_prefix=nil)
38
+ return nil unless setup?
39
+ @release_name = @_configuration[:release_name] if @release_name.nil?
40
+ @_log_file_path = @_log_path + @release_name + ".log" unless @_log_file_path
41
+ @_deploy_log_file = File.open(@_log_file_path, "w") if @_deploy_log_file.nil?
42
+
43
+ indent = "%*s" % [Logger::MAX_LEVEL, "*" * (Logger::MAX_LEVEL - level)]
44
+ message.each do |line|
45
+ if line_prefix
46
+ @_deploy_log_file << "#{indent} [#{line_prefix}] #{line.strip}\n"
47
+ else
48
+ @_deploy_log_file << "#{indent} #{line.strip}\n"
49
+ end
50
+ end
51
+ end
52
+
53
+ def self.post_process
54
+ unless ::Interrupt === $!
55
+ puts "\n\nPlease wait while the log file is processed\n"
56
+ # Should dump the stack trace of an exception if there is one
57
+ error = $!
58
+ unless error.nil?
59
+ @_deploy_log_file << error.message << "\n"
60
+ @_deploy_log_file << error.backtrace.join("\n")
61
+ @_success = false
62
+ end
63
+ self.close
64
+
65
+ hooks = [:any]
66
+ hooks << self.successful? ? :success : :failure
67
+ puts "Executing Post Processing Hooks"
68
+ hooks.each do |h|
69
+ @_post_process_hooks[h].each do |key|
70
+ @_configuration.parent.find_and_execute_task(key)
71
+ end
72
+ end
73
+ puts "Finished Post Processing Hooks"
74
+ end
75
+ end
76
+
77
+ # Adds a post processing hook.
78
+ #
79
+ # Provide a task name to execute. These tasks are executed after capistrano has actually run its course.
80
+ #
81
+ # Takes a key to control when the hook is executed.'
82
+ # :any - always executed
83
+ # :success - only execute on success
84
+ # :failure - only execute on failure
85
+ #
86
+ # ==== Example
87
+ # Capistrano::EYLogger.post_process_hook( "ey_logger:upload_log_to_slice", :any)
88
+ #
89
+ def self.post_process_hook(task, key = :any)
90
+ @_post_process_hooks ||= Hash.new{|h,k| h[k] = []}
91
+ @_post_process_hooks[key] << task
92
+ end
93
+
94
+ def self.setup?
95
+ !!@_setup
96
+ end
97
+
98
+ def self.deploy_type
99
+ @_deploy_type
100
+ end
101
+
102
+ def self.successful?
103
+ !!@_success
104
+ end
105
+
106
+ def self.failure?
107
+ !@_success
108
+ end
109
+
110
+ def self.log_file_path
111
+ @_log_file_path
112
+ end
113
+
114
+ def self.remote_log_file_name
115
+ @_log_file_name ||= "#{@_configuration[:release_name]}-#{@_deploy_type}-#{self.successful? ? "SUCCESS" : "FAILURE"}.log"
116
+ end
117
+
118
+ def self.close
119
+ @_deploy_log_file.flush unless @_deploy_log_file.nil?
120
+ @_deploy_log_file.close unless @_deploy_log_file.nil?
121
+ @_setup = false
122
+ end
123
+
124
+ end
125
+ end