kelredd-useful 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,8 @@ Capistrano::Configuration.instance.load do
9
9
  # These tasks override the default cap migration tasks
10
10
  # => allows for running your migrations on the primary app server only
11
11
 
12
- desc "_: (#{application}) Bring down site, deploy with migrations on primary app server only, bring site back up."
13
- task :migrations, :roles => :app, :only => { :primary => true } do
12
+ desc "_: (useful) Stop, update, migrate, start"
13
+ task :migrations, :roles => :app do
14
14
  stop
15
15
  update
16
16
  migrate
@@ -19,8 +19,7 @@ Capistrano::Configuration.instance.load do
19
19
 
20
20
  # Copied from http://github.com/jamis/capistrano/blob/df0935c4c135207582da343aacdd4cf080fcfed0/lib/capistrano/recipes/deploy.rb
21
21
  # => changed :roles => :db to :roles => :app so that migrations will run on the primary app server only
22
- # => also added , :pty => false as an argument on the run command
23
- desc "_: (#{application}) port of default cap task to only run on primary app server"
22
+ desc "_: (useful) port of default cap task to only run on primary app server"
24
23
  task :migrate, :roles => :app, :only => { :primary => true } do
25
24
  rake = fetch(:rake, "rake")
26
25
  rails_env = fetch(:rails_env, "production")
@@ -6,7 +6,7 @@ Capistrano::Configuration.instance.load do
6
6
 
7
7
  namespace :deploy do
8
8
 
9
- desc "_: (#{application}) no migrating needed, this one does nothing..."
9
+ desc "_: (useful) no migrating needed, this one does nothing..."
10
10
  task :migrate, :roles => :app, :only => { :primary => true } do
11
11
  end
12
12
 
@@ -0,0 +1,32 @@
1
+ unless Capistrano::Configuration.respond_to?(:instance)
2
+ abort "useful/cap_tasks requires Capistrano 2"
3
+ end
4
+
5
+ Capistrano::Configuration.instance.load do
6
+
7
+ set :down_html, "down"
8
+
9
+ namespace :deploy do
10
+
11
+ after 'deploy:update_code', 'deploy:update_down_html'
12
+
13
+ desc "_: (useful) Updates the shared down html page with the version from source"
14
+ task :update_down_html, :roles => :app, :except => { :no_release => true } do
15
+ run "cp #{shared_path}/#{down_html}.html #{current_path}/public/#{down_html}.html"
16
+ end
17
+
18
+ namespace :web do
19
+ desc "_: (useful) Remove the down html page."
20
+ task :enable, :roles => :app, :except => { :no_release => true } do
21
+ run "rm #{current_path}/public/#{down_html}.html"
22
+ end
23
+
24
+ desc "_: (useful) Put up the down html page"
25
+ task :disable, :roles => :app, :except => { :no_release => true } do
26
+ run "cp #{shared_path}/#{down_html}.html #{current_path}/public/#{down_html}.html"
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -4,13 +4,23 @@ end
4
4
 
5
5
  Capistrano::Configuration.instance.load do
6
6
 
7
+ set :real_revision, "blahblahblahnotthis"
8
+
7
9
  namespace :deploy do
8
10
 
9
- task :before_update_code, :except => { :no_release => true } do
11
+ before 'deploy:update_code', 'deploy:set_git_branch'
12
+ before 'deploy:update_code', 'deploy:lookup_git_revision'
10
13
 
14
+ desc '_: (useful) Set branch to current git branch'
15
+ task :set_git_branch, :roles => :app, :only => { :primary => true } do
11
16
  # Set the branch name to current git HEAD if this stage is configured that way
12
- set :branch, run_locally("git symbolic-ref HEAD 2>/dev/null").split('/').last.strip if branch == :current_git_branch
17
+ if branch == :current_git_branch
18
+ set :branch, run_locally("git symbolic-ref HEAD 2>/dev/null").split('/').last.strip
19
+ end
20
+ end
13
21
 
22
+ desc '_: (useful) Get git revision from server to avoid typing password'
23
+ task :lookup_git_revision, :roles => :app, :only => { :primary => true } do
14
24
  # hack to remotely lookup the revision sending the config'd scm_password
15
25
  # => prevents having to enter it locally
16
26
  set :real_revision, source.local.query_revision(revision) { |cmd|
@@ -25,7 +35,7 @@ Capistrano::Configuration.instance.load do
25
35
  }
26
36
  }
27
37
  end
28
-
38
+
29
39
  end
30
40
 
31
41
  end
@@ -6,39 +6,36 @@ Capistrano::Configuration.instance.load do
6
6
 
7
7
  namespace :deploy do
8
8
 
9
- task :after_deploy, :except => { :no_release => true } do
9
+ after 'deploy:setup', 'deploy:create_apache_log_folder'
10
+ after 'deploy', 'deploy:cleanup_deploy'
11
+
12
+ desc '_: (useful) Create the shared log/apache2 folder'
13
+ task :create_apache_log_folder, :roles => :app, :except => { :no_release => true } do
14
+ run "mkdir -p #{shared_path}/log/apache2/"
15
+ end
16
+
17
+ desc "_: (useful) Enables web and runs deploy:cleanup"
18
+ task :cleanup_deploy, :roles => :app, :except => { :no_release => true } do
10
19
  web.enable
11
20
  cleanup
12
21
  end
13
-
14
- desc "_: (#{application}) Start app from cold state."
22
+
23
+ desc "_: (useful) Restarts app and enables web"
15
24
  task :start, :roles => :app, :except => { :no_release => true } do
16
25
  restart
17
26
  web.enable
18
27
  end
19
28
 
20
- desc "_: (#{application}) Stop app and put in cold state."
29
+ desc "_: (useful) Disables web"
21
30
  task :stop, :roles => :app, :except => { :no_release => true } do
22
31
  web.disable
23
32
  end
24
33
 
25
- desc "_: (#{application}) Restart app from hot state."
34
+ desc "_: (useful) touches tmp/restart.txt"
26
35
  task :restart, :roles => :app, :except => { :no_release => true } do
27
36
  run "touch #{current_path}/tmp/restart.txt"
28
37
  end
29
38
 
30
- namespace :web do
31
- desc "_: (#{application}) Enable app and remove down page."
32
- task :enable, :roles => :app, :except => { :no_release => true } do
33
- run "rm #{current_path}/public/#{down_html}.html"
34
- end
35
-
36
- desc "_: (#{application}) Put up down page and disable app"
37
- task :disable, :roles => :app, :except => { :no_release => true } do
38
- run "cp #{shared_path}/#{down_html}.html #{current_path}/public/#{down_html}.html"
39
- end
40
- end
41
-
42
39
  end
43
40
 
44
41
  end
@@ -4,9 +4,28 @@ end
4
4
 
5
5
  Capistrano::Configuration.instance.load do
6
6
 
7
- namespace :cache do
7
+ namespace :deploy do
8
+
9
+ after 'deploy:setup', 'deploy:create_apache_log_folder'
10
+ after 'deploy:update_code', 'deploy:link_cache_folders'
11
+
12
+ desc '_: (useful) Creates the shared cache folders'
13
+ task :create_cache_folders, :roles => :app, :except => { :no_release => true } do
14
+ run "mkdir -p #{shared_path}/cache; chmod 775 #{shared_path}/cache"
15
+ run "mkdir -p #{shared_path}/cache-rack; chmod 775 #{shared_path}/cache-rack"
16
+ end
17
+
18
+ desc '_: (useful) Links the shared cache folders into the public directory'
19
+ task :link_cache_folders, :roles => :app, :except => { :no_release => true } do
20
+ run "ln -s #{shared_path}/cache #{release_path}/public"
21
+ run "ln -s #{shared_path}/cache-rack #{release_path}"
22
+ end
23
+
24
+ end
8
25
 
9
- desc "Clear the Rack cache"
26
+ namespace :cache do
27
+
28
+ desc "_: (useful) Clear the rack cache"
10
29
  task :xrack, :roles => :app, :except => { :no_release => true } do
11
30
  run "rm -rf #{shared_path}/cache-rack/body/*"
12
31
  run "rm -rf #{shared_path}/cache-rack/meta/*"
@@ -3,7 +3,7 @@ module Useful
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- TINY = 6
6
+ TINY = 7
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-useful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-28 00:00:00 -06:00
12
+ date: 2010-01-09 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -37,6 +37,7 @@ files:
37
37
  - lib/useful/active_record_helpers.rb
38
38
  - lib/useful/cap_tasks/app_role_migrations.rb
39
39
  - lib/useful/cap_tasks/disable_migrate.rb
40
+ - lib/useful/cap_tasks/disable_with_down_html.rb
40
41
  - lib/useful/cap_tasks/git_query_revision_remote.rb
41
42
  - lib/useful/cap_tasks/globals.rb
42
43
  - lib/useful/cap_tasks/passenger_deploy.rb