squirrel-eycap 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,147 @@
1
+ == 0.4.10 / 2009-06-24
2
+ * using nohup on nginx start and restart
3
+
4
+ == 0.4.9 / 2009-06-22
5
+ * added nginx reload, upgrade and configtest - thanks Randy (ydnar)
6
+
7
+ == 0.4.8 / there is no 0.4.8, just like there is no spoon.
8
+
9
+ == 0.4.7 / 2009-05-12
10
+ * fixed bug in clone_prod_to_staging and clone_to_local db tasks for postgres
11
+ where the regex matching the password prompt for the restore was wrong
12
+
13
+ == 0.4.6 / 2009-03-24
14
+ * fixed bug to restore clone_prod_to_staging using the compressed file
15
+
16
+ == 0.4.5 / 2009-03-03
17
+ * happy square root day!
18
+ * added the staging restore to db:clone_prod_to_staging
19
+
20
+ == 0.4.4 / 2009-03-03
21
+ * happy square root day!
22
+ * fixed the *correct* database.rb file for the db:clone_prod_to_staging
23
+
24
+ == 0.4.3 / 2009-02-11
25
+ * updated db:dump command for Engine Yard Solo offering, fixing a bug where
26
+ the dbname wasn't included.
27
+
28
+ == 0.4.2 / 2009-02-11
29
+ * added condition to determine if the db:dump command is run against our
30
+ traditional offering or the new cloud offering
31
+ * fixed bug where if a production db host name doesn't have a -master at the
32
+ end it won't run the db:clone_prod_to_staging correctly
33
+
34
+ == 0.4.1 / 2009-01-09
35
+ * fixed bug for passenger:restart
36
+
37
+ == 0.4.0 / 2009-01-09
38
+ * add passenger:restart task
39
+ * add apache stop, start, restart and reload tasks
40
+ * Don't display database passwords in the logs, output, etc. use stdin instead
41
+
42
+ == 0.3.11 / 2008-11-09
43
+ * filtered_remote_cache uses svn switch
44
+
45
+ == 0.3.9 / 2008-09-29
46
+ * add reindex task for /engineyard/bin/acts_as_sphinx_searchd
47
+ * add reindex and configure task for /engineyard/bin/ultrasphinx_searchd
48
+ * add reindex and configure task for /engineyard/bin/thinking_sphinx_searchd
49
+
50
+ == 0.3.8 / 2008-09-22
51
+ * add PostgreSQL support to the database.rb recipe.
52
+
53
+ == 0.3.7 / 2008-08-23
54
+ * fix from customer for filtered_remote_cache to just use plain grep.
55
+
56
+ == 0.3.6 / 2008-07-17
57
+ * features updated VERSION
58
+
59
+ == 0.3.5 / 2008-07-17
60
+ * filtered_remote_cache uses cached checkout's repository root for comparison for speedier tagged/branched deploys
61
+
62
+ == 0.3.4 / 2008-06-17
63
+ * rake install_gem_no_doc for faster install
64
+ * set role to db for backup_name task
65
+ * add migration support for merb
66
+
67
+ == 0.3.3 / 2008-05-07
68
+ * add ey_logger to log deploys to server
69
+
70
+ == 0.3.2 / 2008-04-29
71
+ * 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
72
+ * only clone from replica database
73
+ * remove call to variable in task desc
74
+ * fix ferret symlinking
75
+ * gemspec for github
76
+
77
+ == 0.3.1 / 2008-03-17
78
+ * Make the custom maintenance pages actually work!
79
+
80
+ == 0.3.0 / 2008-03-05
81
+ * Adding custom maintenance pages is now as easy as copying a custom html file to #{shared_path}/system/maintenance.html.custom
82
+
83
+ == 0.2.10 / 2008-03-02
84
+ * Symlink memcached.yml only on :memcached => true, except :no_release => true
85
+
86
+ == 0.2.9 / 2008-02-27
87
+ * Fix a bug with ultrasphinx:configure running on multiple hosts
88
+
89
+ == 0.2.8 / 2008-02-20
90
+ * Add tasks for solr starting,stopping, and log tailing.
91
+ * Add monit namespace and make appservers php/merb compatible
92
+ * Make ultrasphinx symlinking a little smarter
93
+ * Add tomcat tasks for spongecell
94
+
95
+ == 0.2.6 / 2008-02-14
96
+ * Make mongrel restarts only apply to mongrel slices
97
+
98
+ == 0.2.5 / 2008-02-11
99
+ * Added db cloning task
100
+
101
+ == 0.2.4 / 2008-02-06
102
+ * Symlink memcached.yml in on deploy if you enable the callback
103
+
104
+ == 0.2.3 / 2008-02-01
105
+ * Make log tailing environmentally aware. Also add tasks to tail mongrel logs
106
+
107
+ == 0.2.2 / 2008-01-25
108
+ * sphinx:configure ultrasphinx configuration task
109
+
110
+ == 0.2.1 / 2008-01-25
111
+ * override default deploy recipe start/stop tasks
112
+
113
+ == 0.2.0 / 2008-01-23
114
+ * sphinx:symlink ultrasphinx configuration directory
115
+
116
+ == 0.1.9 / 2008-01-21
117
+ * Correct memcached tasks.
118
+
119
+ == 0.1.8 / 2008-01-20
120
+ * Add memcached tasks
121
+
122
+ == 0.1.7 / 2008-01-19
123
+ * fix symlink_configs task
124
+
125
+ == 0.1.6 / 2008-01-19
126
+ * add restart tasks for backgroundrb
127
+
128
+ == 0.1.5 / 2008-01-18
129
+ * fixed bug in filtered_remote_cache that prevented a changed checkout URL from taking over the cache
130
+
131
+ == 0.1.4 / 2008-01-17
132
+ * added sphinx:[reindex|start|stop|restart] matches only app servers with :sphinx => true
133
+
134
+ == 0.1.3 / 2008-01-17
135
+ * filtered_remote_cache to removes the cached copy of the source URL changed
136
+
137
+ == 0.1.2 / 2008-01-15
138
+ * added filtered_remote_cache capistrano deployment strategy
139
+
140
+ == 0.1.1 / 2008-01-15
141
+ * removed database tasks until problem with 'defer' is solved
142
+
143
+ == 0.1.0 / 2008-01-14
144
+ * Bugfix for empty :application variable
145
+
146
+ == 0.0.1 / 2008-01-14
147
+ * Initial release
data/Manifest.txt ADDED
@@ -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
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,56 @@
1
+ require 'capistrano/recipes/deploy/strategy/remote'
2
+
3
+ module Capistrano
4
+ module Deploy
5
+ module Strategy
6
+
7
+ # Implements the deployment strategy that keeps a cached checkout of
8
+ # the source code on each remote server. Each deploy simply updates the
9
+ # cached checkout, and then does a copy from the cached copy to the
10
+ # final deployment location.
11
+ class RemoteCache < Remote
12
+ # Executes the SCM command for this strategy and writes the REVISION
13
+ # mark file to each host.
14
+ def deploy!
15
+ update_repository_cache
16
+ copy_repository_cache
17
+ end
18
+
19
+ def check!
20
+ super.check do |d|
21
+ d.remote.writable(shared_path)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def repository_cache
28
+ File.join(configuration[:repository_cache] || "cached-copy")
29
+ end
30
+
31
+ def update_repository_cache
32
+ logger.trace "updating the cached checkout on all servers"
33
+ command = "if [ -d #{repository_cache} ]; then " +
34
+ "#{source.sync(revision, repository_cache)}; " +
35
+ "else #{source.checkout(revision, repository_cache)}; fi"
36
+ scm_run(command)
37
+ end
38
+
39
+ def copy_repository_cache
40
+ logger.trace "copying the cached version to #{configuration[:release_path]}"
41
+ if copy_exclude.empty?
42
+ run "cp -RPp #{repository_cache} #{configuration[:release_path]} && #{mark}"
43
+ else
44
+ exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
45
+ run "rsync -lrp #{exclusions} #{repository_cache}/* #{configuration[:release_path]} && #{mark}"
46
+ end
47
+ end
48
+
49
+ def copy_exclude
50
+ @copy_exclude ||= Array(configuration.fetch(:copy_exclude, []))
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
data/lib/eycap.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Eycap
2
+ VERSION = '0.4.10'
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