eycap 0.4.16

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,169 @@
1
+ == 0.4.16 / 2009-09-30
2
+ * apps ping weather app before and after each deploy
3
+
4
+ == 0.4.15 / 2009-09-02
5
+ * added include in gemspec for bundler file
6
+
7
+ == 0.4.14 / 2009-08-31
8
+ * restored functionality to remove temporary compressed sql file after db:clone_prod_to_staging
9
+ * renamed gz extension files to bz2 in db:clone_to_local
10
+ * memcached: fix netcat not hanging up on a flush
11
+
12
+ == 0.4.13 / 2009-07-30
13
+ * changed Gemfile to absolute path
14
+ * merged changes from square/master for unshared_remote_cache cached deploy strategy
15
+
16
+ == 0.4.12 / 2009-06-26
17
+ * removed condition for dbhost that was useless and tested db:clone_prod_to_staging
18
+
19
+ == 0.4.11 / 2009-06-25
20
+ * changed nginx start and restart to give output to cap
21
+ * fixed db:clone_to_local task
22
+
23
+ == 0.4.10 / 2009-06-24
24
+ * using nohup on nginx start and restart
25
+
26
+ == 0.4.9 / 2009-06-22
27
+ * added nginx reload, upgrade and configtest - thanks Randy (ydnar)
28
+
29
+ == 0.4.8 / there is no 0.4.8, just like there is no spoon.
30
+
31
+ == 0.4.7 / 2009-05-12
32
+ * fixed bug in clone_prod_to_staging and clone_to_local db tasks for postgres
33
+ where the regex matching the password prompt for the restore was wrong
34
+
35
+ == 0.4.6 / 2009-03-24
36
+ * fixed bug to restore clone_prod_to_staging using the compressed file
37
+
38
+ == 0.4.5 / 2009-03-03
39
+ * happy square root day!
40
+ * added the staging restore to db:clone_prod_to_staging
41
+
42
+ == 0.4.4 / 2009-03-03
43
+ * happy square root day!
44
+ * fixed the *correct* database.rb file for the db:clone_prod_to_staging
45
+
46
+ == 0.4.3 / 2009-02-11
47
+ * updated db:dump command for Engine Yard Solo offering, fixing a bug where
48
+ the dbname wasn't included.
49
+
50
+ == 0.4.2 / 2009-02-11
51
+ * added condition to determine if the db:dump command is run against our
52
+ traditional offering or the new cloud offering
53
+ * fixed bug where if a production db host name doesn't have a -master at the
54
+ end it won't run the db:clone_prod_to_staging correctly
55
+
56
+ == 0.4.1 / 2009-01-09
57
+ * fixed bug for passenger:restart
58
+
59
+ == 0.4.0 / 2009-01-09
60
+ * add passenger:restart task
61
+ * add apache stop, start, restart and reload tasks
62
+ * Don't display database passwords in the logs, output, etc. use stdin instead
63
+
64
+ == 0.3.11 / 2008-11-09
65
+ * filtered_remote_cache uses svn switch
66
+
67
+ == 0.3.9 / 2008-09-29
68
+ * add reindex task for /engineyard/bin/acts_as_sphinx_searchd
69
+ * add reindex and configure task for /engineyard/bin/ultrasphinx_searchd
70
+ * add reindex and configure task for /engineyard/bin/thinking_sphinx_searchd
71
+
72
+ == 0.3.8 / 2008-09-22
73
+ * add PostgreSQL support to the database.rb recipe.
74
+
75
+ == 0.3.7 / 2008-08-23
76
+ * fix from customer for filtered_remote_cache to just use plain grep.
77
+
78
+ == 0.3.6 / 2008-07-17
79
+ * features updated VERSION
80
+
81
+ == 0.3.5 / 2008-07-17
82
+ * filtered_remote_cache uses cached checkout's repository root for comparison for speedier tagged/branched deploys
83
+
84
+ == 0.3.4 / 2008-06-17
85
+ * rake install_gem_no_doc for faster install
86
+ * set role to db for backup_name task
87
+ * add migration support for merb
88
+
89
+ == 0.3.3 / 2008-05-07
90
+ * add ey_logger to log deploys to server
91
+
92
+ == 0.3.2 / 2008-04-29
93
+ * 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
94
+ * only clone from replica database
95
+ * remove call to variable in task desc
96
+ * fix ferret symlinking
97
+ * gemspec for github
98
+
99
+ == 0.3.1 / 2008-03-17
100
+ * Make the custom maintenance pages actually work!
101
+
102
+ == 0.3.0 / 2008-03-05
103
+ * Adding custom maintenance pages is now as easy as copying a custom html file to #{shared_path}/system/maintenance.html.custom
104
+
105
+ == 0.2.10 / 2008-03-02
106
+ * Symlink memcached.yml only on :memcached => true, except :no_release => true
107
+
108
+ == 0.2.9 / 2008-02-27
109
+ * Fix a bug with ultrasphinx:configure running on multiple hosts
110
+
111
+ == 0.2.8 / 2008-02-20
112
+ * Add tasks for solr starting,stopping, and log tailing.
113
+ * Add monit namespace and make appservers php/merb compatible
114
+ * Make ultrasphinx symlinking a little smarter
115
+ * Add tomcat tasks for spongecell
116
+
117
+ == 0.2.6 / 2008-02-14
118
+ * Make mongrel restarts only apply to mongrel slices
119
+
120
+ == 0.2.5 / 2008-02-11
121
+ * Added db cloning task
122
+
123
+ == 0.2.4 / 2008-02-06
124
+ * Symlink memcached.yml in on deploy if you enable the callback
125
+
126
+ == 0.2.3 / 2008-02-01
127
+ * Make log tailing environmentally aware. Also add tasks to tail mongrel logs
128
+
129
+ == 0.2.2 / 2008-01-25
130
+ * sphinx:configure ultrasphinx configuration task
131
+
132
+ == 0.2.1 / 2008-01-25
133
+ * override default deploy recipe start/stop tasks
134
+
135
+ == 0.2.0 / 2008-01-23
136
+ * sphinx:symlink ultrasphinx configuration directory
137
+
138
+ == 0.1.9 / 2008-01-21
139
+ * Correct memcached tasks.
140
+
141
+ == 0.1.8 / 2008-01-20
142
+ * Add memcached tasks
143
+
144
+ == 0.1.7 / 2008-01-19
145
+ * fix symlink_configs task
146
+
147
+ == 0.1.6 / 2008-01-19
148
+ * add restart tasks for backgroundrb
149
+
150
+ == 0.1.5 / 2008-01-18
151
+ * fixed bug in filtered_remote_cache that prevented a changed checkout URL from taking over the cache
152
+
153
+ == 0.1.4 / 2008-01-17
154
+ * added sphinx:[reindex|start|stop|restart] matches only app servers with :sphinx => true
155
+
156
+ == 0.1.3 / 2008-01-17
157
+ * filtered_remote_cache to removes the cached copy of the source URL changed
158
+
159
+ == 0.1.2 / 2008-01-15
160
+ * added filtered_remote_cache capistrano deployment strategy
161
+
162
+ == 0.1.1 / 2008-01-15
163
+ * removed database tasks until problem with 'defer' is solved
164
+
165
+ == 0.1.0 / 2008-01-14
166
+ * Bugfix for empty :application variable
167
+
168
+ == 0.0.1 / 2008-01-14
169
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,29 @@
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/unshared_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/bundler.rb
14
+ lib/eycap/recipes/deploy.rb
15
+ lib/eycap/recipes/ferret.rb
16
+ lib/eycap/recipes/juggernaut.rb
17
+ lib/eycap/recipes/memcached.rb
18
+ lib/eycap/recipes/mongrel.rb
19
+ lib/eycap/recipes/monit.rb
20
+ lib/eycap/recipes/nginx.rb
21
+ lib/eycap/recipes/slice.rb
22
+ lib/eycap/recipes/solr.rb
23
+ lib/eycap/recipes/sphinx.rb
24
+ lib/eycap/recipes/templates/maintenance.rhtml
25
+ lib/eycap/recipes/tomcat.rb
26
+ lib/eycap/recipes/passenger.rb
27
+ lib/eycap/recipes/apache.rb
28
+ test/test_eycap.rb
29
+ test/test_helper.rb
data/README.txt ADDED
@@ -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.
data/Rakefile ADDED
@@ -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
data/lib/eycap.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Eycap
2
+ VERSION = '0.4.16'
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