gabetax-eycap 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,189 @@
1
+ == 0.5.5 / 2009-3-16
2
+ * fixed 2 bugs that are in 0.5.4 with the SSL and bundler recipes
3
+ * use this version with bundler version 0.9.2
4
+
5
+ == 0.5.4 / 2009-3-16
6
+ * fixed gem bundler issue
7
+
8
+ == 0.5.3 / 2009-1-27
9
+ * created task cap ssl:create
10
+ * use this version with bundler version 0.8
11
+
12
+ == 0.5.2 / 2009-12-17
13
+ * renamed task cap slice:tail_production_logs to cap slice:tail_environment_logs
14
+
15
+ == 0.5.1 / 2009-11-12
16
+ * using bundler's cache instead of symlinking on each deploy.
17
+
18
+ == 0.5.0 / 2009-10-07
19
+ * moved from github to gemcutter for hosting.
20
+
21
+ == 0.4.16 / 2009-09-30
22
+ * apps ping weather app before and after each deploy
23
+
24
+ == 0.4.15 / 2009-09-02
25
+ * added include in gemspec for bundler file
26
+
27
+ == 0.4.14 / 2009-08-31
28
+ * restored functionality to remove temporary compressed sql file after db:clone_prod_to_staging
29
+ * renamed gz extension files to bz2 in db:clone_to_local
30
+ * memcached: fix netcat not hanging up on a flush
31
+
32
+ == 0.4.13 / 2009-07-30
33
+ * changed Gemfile to absolute path
34
+ * merged changes from square/master for unshared_remote_cache cached deploy strategy
35
+
36
+ == 0.4.12 / 2009-06-26
37
+ * removed condition for dbhost that was useless and tested db:clone_prod_to_staging
38
+
39
+ == 0.4.11 / 2009-06-25
40
+ * changed nginx start and restart to give output to cap
41
+ * fixed db:clone_to_local task
42
+
43
+ == 0.4.10 / 2009-06-24
44
+ * using nohup on nginx start and restart
45
+
46
+ == 0.4.9 / 2009-06-22
47
+ * added nginx reload, upgrade and configtest - thanks Randy (ydnar)
48
+
49
+ == 0.4.8 / there is no 0.4.8, just like there is no spoon.
50
+
51
+ == 0.4.7 / 2009-05-12
52
+ * fixed bug in clone_prod_to_staging and clone_to_local db tasks for postgres
53
+ where the regex matching the password prompt for the restore was wrong
54
+
55
+ == 0.4.6 / 2009-03-24
56
+ * fixed bug to restore clone_prod_to_staging using the compressed file
57
+
58
+ == 0.4.5 / 2009-03-03
59
+ * happy square root day!
60
+ * added the staging restore to db:clone_prod_to_staging
61
+
62
+ == 0.4.4 / 2009-03-03
63
+ * happy square root day!
64
+ * fixed the *correct* database.rb file for the db:clone_prod_to_staging
65
+
66
+ == 0.4.3 / 2009-02-11
67
+ * updated db:dump command for Engine Yard Solo offering, fixing a bug where
68
+ the dbname wasn't included.
69
+
70
+ == 0.4.2 / 2009-02-11
71
+ * added condition to determine if the db:dump command is run against our
72
+ traditional offering or the new cloud offering
73
+ * fixed bug where if a production db host name doesn't have a -master at the
74
+ end it won't run the db:clone_prod_to_staging correctly
75
+
76
+ == 0.4.1 / 2009-01-09
77
+ * fixed bug for passenger:restart
78
+
79
+ == 0.4.0 / 2009-01-09
80
+ * add passenger:restart task
81
+ * add apache stop, start, restart and reload tasks
82
+ * Don't display database passwords in the logs, output, etc. use stdin instead
83
+
84
+ == 0.3.11 / 2008-11-09
85
+ * filtered_remote_cache uses svn switch
86
+
87
+ == 0.3.9 / 2008-09-29
88
+ * add reindex task for /engineyard/bin/acts_as_sphinx_searchd
89
+ * add reindex and configure task for /engineyard/bin/ultrasphinx_searchd
90
+ * add reindex and configure task for /engineyard/bin/thinking_sphinx_searchd
91
+
92
+ == 0.3.8 / 2008-09-22
93
+ * add PostgreSQL support to the database.rb recipe.
94
+
95
+ == 0.3.7 / 2008-08-23
96
+ * fix from customer for filtered_remote_cache to just use plain grep.
97
+
98
+ == 0.3.6 / 2008-07-17
99
+ * features updated VERSION
100
+
101
+ == 0.3.5 / 2008-07-17
102
+ * filtered_remote_cache uses cached checkout's repository root for comparison for speedier tagged/branched deploys
103
+
104
+ == 0.3.4 / 2008-06-17
105
+ * rake install_gem_no_doc for faster install
106
+ * set role to db for backup_name task
107
+ * add migration support for merb
108
+
109
+ == 0.3.3 / 2008-05-07
110
+ * add ey_logger to log deploys to server
111
+
112
+ == 0.3.2 / 2008-04-29
113
+ * 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
114
+ * only clone from replica database
115
+ * remove call to variable in task desc
116
+ * fix ferret symlinking
117
+ * gemspec for github
118
+
119
+ == 0.3.1 / 2008-03-17
120
+ * Make the custom maintenance pages actually work!
121
+
122
+ == 0.3.0 / 2008-03-05
123
+ * Adding custom maintenance pages is now as easy as copying a custom html file to #{shared_path}/system/maintenance.html.custom
124
+
125
+ == 0.2.10 / 2008-03-02
126
+ * Symlink memcached.yml only on :memcached => true, except :no_release => true
127
+
128
+ == 0.2.9 / 2008-02-27
129
+ * Fix a bug with ultrasphinx:configure running on multiple hosts
130
+
131
+ == 0.2.8 / 2008-02-20
132
+ * Add tasks for solr starting,stopping, and log tailing.
133
+ * Add monit namespace and make appservers php/merb compatible
134
+ * Make ultrasphinx symlinking a little smarter
135
+ * Add tomcat tasks for spongecell
136
+
137
+ == 0.2.6 / 2008-02-14
138
+ * Make mongrel restarts only apply to mongrel slices
139
+
140
+ == 0.2.5 / 2008-02-11
141
+ * Added db cloning task
142
+
143
+ == 0.2.4 / 2008-02-06
144
+ * Symlink memcached.yml in on deploy if you enable the callback
145
+
146
+ == 0.2.3 / 2008-02-01
147
+ * Make log tailing environmentally aware. Also add tasks to tail mongrel logs
148
+
149
+ == 0.2.2 / 2008-01-25
150
+ * sphinx:configure ultrasphinx configuration task
151
+
152
+ == 0.2.1 / 2008-01-25
153
+ * override default deploy recipe start/stop tasks
154
+
155
+ == 0.2.0 / 2008-01-23
156
+ * sphinx:symlink ultrasphinx configuration directory
157
+
158
+ == 0.1.9 / 2008-01-21
159
+ * Correct memcached tasks.
160
+
161
+ == 0.1.8 / 2008-01-20
162
+ * Add memcached tasks
163
+
164
+ == 0.1.7 / 2008-01-19
165
+ * fix symlink_configs task
166
+
167
+ == 0.1.6 / 2008-01-19
168
+ * add restart tasks for backgroundrb
169
+
170
+ == 0.1.5 / 2008-01-18
171
+ * fixed bug in filtered_remote_cache that prevented a changed checkout URL from taking over the cache
172
+
173
+ == 0.1.4 / 2008-01-17
174
+ * added sphinx:[reindex|start|stop|restart] matches only app servers with :sphinx => true
175
+
176
+ == 0.1.3 / 2008-01-17
177
+ * filtered_remote_cache to removes the cached copy of the source URL changed
178
+
179
+ == 0.1.2 / 2008-01-15
180
+ * added filtered_remote_cache capistrano deployment strategy
181
+
182
+ == 0.1.1 / 2008-01-15
183
+ * removed database tasks until problem with 'defer' is solved
184
+
185
+ == 0.1.0 / 2008-01-14
186
+ * Bugfix for empty :application variable
187
+
188
+ == 0.0.1 / 2008-01-14
189
+ * Initial release
@@ -0,0 +1,30 @@
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
+ lib/eycap/recipes/ssl.rb
29
+ test/test_eycap.rb
30
+ test/test_helper.rb
@@ -0,0 +1,66 @@
1
+ = eycap
2
+
3
+ == DESCRIPTION:
4
+
5
+ Engine Yard capistrano tasks for use specifically with Engine Yard private cloud 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 install gemcutter # installs the gemcutter gem
18
+ $ gem tumble # puts gemcutter as your top source
19
+ $ gem install eycap # installs the latest eycap version
20
+
21
+ == SOURCE:
22
+
23
+ eycap's git repo is available on GitHub, which can be browsed at:
24
+
25
+ http://github.com/engineyard/eycap
26
+
27
+ and cloned from:
28
+
29
+ git://github.com/engineyard/eycap.git
30
+
31
+ == USAGE:
32
+
33
+ === Include in capistrano
34
+
35
+ In your deploy.rb, simply include this line at the top:
36
+
37
+ require 'eycap/recipes'
38
+
39
+ === Filtered remote cache
40
+
41
+ To use filtered_remote_cache, simply:
42
+
43
+ set :deploy_via, :filtered_remote_cache
44
+
45
+ == LICENSE:
46
+
47
+ Copyright (c) 2008-2009 Engine Yard
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ "Software"), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
64
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
65
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
66
+ 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 = 'appsupport@engineyard.com'
8
+ p.summary = 'Capistrano tasks for Engine Yard private cloud slices'
9
+ p.description = 'A bunch of useful recipes to help deployment to Engine Yard private cloud slices'
10
+ p.url = 'http://github.com/engineyard/eycap'
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,5 @@
1
+ module Eycap
2
+
3
+ VERSION = '0.5.5'
4
+
5
+ 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