thunder_punch 0.0.14 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ *.gem
21
+
22
+ ## PROJECT::SPECIFIC
data/CHANGELOG.mdown CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.1.0 (Jul, 30, 2014)
2
+ * Remove ec2 and less recipes as these are out of date and not in use
3
+ * Change which recipes are loaded by default so that the gem footprint is smaller
4
+ * Change setup such that additional recipes can be opted into as desired
5
+ * Make the roles for each recipe group overridable via an apps deploy file to allow for more complex/unique server setups. Recipes now have very basic default roles assigned and you'll need to define roles you were dependent on before (like :worker) via the new options.
6
+
1
7
  == 0.0.14 (Jan 7, 2013)
2
8
  * Remove references to the :static role (replacing with :worker role as
3
9
  necessary). When using the 'gateway' option in Capistrano having two
data/README.mdown CHANGED
@@ -1,37 +1,46 @@
1
1
  #Thunder Punch
2
2
 
3
- Collection of Capistrano recipes for deployment and other server tasks
3
+ Collection of Capistrano recipes for deployment and other server tasks.
4
4
 
5
- ##Origin
5
+ NOTE: Version 0.1.0 represents a breaking change from 0.0.14 and below. See CHANGELOG for details.
6
6
 
7
- "Thunder Punch" was a version of the He-Man action figure from the original 1980s Masters of the Universe toy line. Ring caps were placed in a "backpack" integrated into the figure, which contained the striking mechanism for the caps (as well as tiny vents to allow smoke from a triggered cap to escape). This mechanism was triggered by drawing the figure's spring-loaded right arm back and releasing it to swing forward; the explosion of the cap was intended to simulate a thunderous noise caused by the supposed superhuman power of the character's punch. [via wikipedia]
7
+ ##Requirements
8
8
 
9
- Because this collection of recipes is for Capistrano and run with the cap command - this seemed a good name, sans the thunderous noise of course (this was found to be disrupting in work environments and cafes).
9
+ * Capistrano >=2.5.5 (not compatible with Capistrano 3)
10
10
 
11
- ##Requirements
11
+ ##Installation
12
12
 
13
- * Capistrano >=2.5.5
14
- * In your deploy.rb file:
15
- * Add line 'require thunder_punch'
16
- * Add line 'set :ec2\_config\_location, File.join(File.dirname(__FILE__), "amazon.yml")'
13
+ * In Gemfile
14
+ ```ruby
15
+ gem 'capistrano', '~> 2.15.5'
16
+ gem 'thunder_punch', '~> 0.1.0'
17
+ end
18
+ ```
17
19
 
18
- ##Recipes
20
+ ###Simple setup
19
21
 
20
- By creating a central and organized system for our tasks we can reduce the content in our deploy.rb files to be project specific and make the addition of new tasks easy and compatible.
22
+ * In config/deploy.rb
23
+ ```ruby
24
+ # deploy recipes - these should be required at the very bottom of deploy.rb
25
+ require 'thunder_punch'
26
+ # optional recipes that you want to make use of go here...
27
+ require 'thunder_punch/recipes/passenger'
28
+ require 'thunder_punch/recipes/thinking_sphinx'
29
+ ```
21
30
 
22
- ###EC2
31
+ ###Complex setup
32
+ *TODO*
23
33
 
24
- * Requires a yaml file named amazon.yml with the appropriate passwords, etc. See the example file.
34
+ ##Reasoning
25
35
 
26
- ####ami.rb
27
- * recipes for uploading necessary keys to server, bundling new AMI, uploading to S3, and registering a AMI
28
- * exclude files and directories from bundling by putting them in an array in amazon.yml
29
- * `ami_excluded_items: ['/home/my_user', '/var/some_secret_stuff']`
36
+ By creating a central and organized system for our tasks we can reduce the content in our deploy.rb files to be project specific and make the addition of new tasks easy and compatible.
37
+
38
+ ##Name Origin
30
39
 
31
- ##Known Issues
40
+ "Thunder Punch" was a version of the He-Man action figure from the original 1980s Masters of the Universe toy line. Ring caps were placed in a "backpack" integrated into the figure, which contained the striking mechanism for the caps (as well as tiny vents to allow smoke from a triggered cap to escape). This mechanism was triggered by drawing the figure's spring-loaded right arm back and releasing it to swing forward; the explosion of the cap was intended to simulate a thunderous noise caused by the supposed superhuman power of the character's punch. [via wikipedia]
32
41
 
33
- ###EC2
42
+ Because this collection of recipes is for Capistrano and run with the cap command - this seemed a good name, sans the thunderous noise of course (this was found to be disrupting in work environments and cafes).
34
43
 
35
- * ec2:create\_new\_ami task doesn't work at the moment due to the ec2:bundle_ami task not returning properly. See the TODO for more info.
44
+ ##License
36
45
 
37
- Copyright (c) 2010-2013 Critical Juncture, released under the MIT license
46
+ Copyright (c) 2010-2014 Critical Juncture, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.1.0
data/lib/thunder_punch.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  unless Capistrano::Configuration.respond_to?(:instance)
2
2
  abort "Requires Capistrano 2"
3
3
  end
4
-
5
- %w(recipes).each do |filename|
6
- Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/#{filename}.rb")}
4
+
5
+ %w(recipes).each do |filename|
6
+ Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/thunder_punch/#{filename}.rb")}
7
7
  end
8
8
 
9
- Dir["#{File.dirname(__FILE__)}/utilities/*.rb"].each { |lib|
9
+ Dir["#{File.dirname(__FILE__)}/thunder_punch/utilities/*.rb"].each { |lib|
10
10
  Capistrano::Configuration.instance.load {load(lib)}
11
- }
11
+ }
@@ -0,0 +1,7 @@
1
+ default_recipes = %w(bundler deployment)
2
+
3
+ default_recipes.each do |recipe|
4
+ Capistrano::Configuration.instance.load {
5
+ load("#{File.dirname(__FILE__)}/recipes/#{recipe}.rb")
6
+ }
7
+ end
@@ -0,0 +1,12 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ _cset :bundler_roles, [:app]
3
+
4
+ namespace :bundler do
5
+ desc "Install and lock bundle"
6
+ task :bundle, :roles => bundler_roles do
7
+ _cset(:excluded_gem_file_groups) { [:development, :test] }
8
+ excluded_groups = excluded_gem_file_groups.reject{|e| e == rails_env.to_sym}.each{|g| g.to_s}.join(' ')
9
+ run "cd #{current_path} && bundle install --deployment --without #{excluded_groups}"
10
+ end
11
+ end
12
+ end
@@ -1,11 +1,13 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ _cset :database_roles, [:db]
3
+
2
4
  #############################################################
3
5
  # Check for Existing Database
4
6
  #############################################################
5
7
 
6
8
  namespace :database do
7
9
  desc "Check to see if database exists"
8
- task :check_database_existence, :roles => [:db], :only => { :primary => true } do
10
+ task :check_database_existence, :roles => database_roles, :only => { :primary => true } do
9
11
  db_exists = false
10
12
  run "mysql -u root -e \"SELECT COUNT(SCHEMA_NAME) FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '#{database_to_check}';\" --batch --reconnect --show-warning --silent" do |ch, stream, data|
11
13
  if stream == :err
@@ -31,42 +33,40 @@ Capistrano::Configuration.instance(:must_exist).load do
31
33
 
32
34
  namespace :database do
33
35
  desc "Dump the current database"
34
- task :backup, :roles => [:db], :only => { :primary => true } do
36
+ task :backup, :roles => database_roles, :only => { :primary => true } do
35
37
  set :database_to_check, remote_db_name # used by the check_database_existence task
36
38
  db_exists = find_and_execute_task('database:check_database_existence')
37
39
 
38
- if db_exists
40
+ if db_exists
39
41
  sudo "sudo mkdir -p #{db_path}"
40
42
  run "mysqldump -u root --opt #{remote_db_name} > #{sql_file_path}"
41
43
  else
42
44
  abort "There is no database named #{remote_db_name} to backup"
43
45
  end
44
- end #end task :backup
45
- end #end namspace
46
+ end
47
+ end
46
48
 
47
49
  #############################################################
48
50
  # Load Remote Staging Database to Local Machine
49
51
  #############################################################
50
52
 
51
53
  namespace :database do
52
-
53
54
  desc "Backup remote database and load locally"
54
- task :load_remote, :roles => [:db], :only => { :primary => true } do
55
+ task :load_remote, :roles => database_roles, :only => { :primary => true } do
55
56
  backup
56
57
  copy
57
58
  load_copy
58
59
  end
59
60
 
60
- desc "Copy the current database"
61
- task :copy, :roles => [:db], :only => { :primary => true } do
61
+ desc "Copy the current database"
62
+ task :copy, :roles => database_roles, :only => { :primary => true } do
62
63
  `mkdir -p tmp`
63
64
  download(sql_file_path, "tmp/", :via=> :scp)
64
65
  end
65
66
 
66
67
  desc "Load the staging database locally"
67
- task :load_copy, :roles => [:db], :only => { :primary => true } do
68
- `script/dbconsole -p < tmp/#{remote_db_name}.sql`
68
+ task :load_copy, :roles => database_roles, :only => { :primary => true } do
69
+ `rails dbconsole -p < tmp/#{remote_db_name}.sql`
69
70
  end
70
-
71
- end #end namspace
72
- end
71
+ end
72
+ end
@@ -1,18 +1,21 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
-
2
+
3
3
  #finalizing deploy is normal behaviour but in some (multi-server) environments we don't want that.
4
4
  _cset :finalize_deploy, true
5
- set :rake, "bundle exec rake"
6
-
5
+ # set rake path if not set
6
+ _cset :rake, "bundle exec rake"
7
+ # set default roles for the deploy task
8
+ _cset :deploy_roles, [:app]
9
+
7
10
  namespace :deploy do
8
11
  desc "Deploy the app"
9
- task :default, :roles => [:app, :worker] do
12
+ task :default, :roles => deploy_roles do
10
13
  update
11
14
  restart
12
15
  end
13
16
 
14
17
  desc "Setup a GitHub-style deployment."
15
- task :setup, :roles => [:app, :worker], :except => { :no_release => true } do
18
+ task :setup, :roles => deploy_roles, :except => { :no_release => true } do
16
19
  run "cd #{deploy_to} && git clone #{repository} #{current_path}"
17
20
  end
18
21
 
@@ -23,13 +26,13 @@ Capistrano::Configuration.instance(:must_exist).load do
23
26
  end
24
27
 
25
28
  desc "Update the deployed code."
26
- task :update_code, :roles => [:app, :worker], :except => { :no_release => true } do
29
+ task :update_code, :roles => deploy_roles, :except => { :no_release => true } do
27
30
  run "cd #{current_path}; git fetch origin; git reset --hard origin/#{branch}; git submodule update --init"
28
- if fetch(:finalize_deploy, true)
31
+ if fetch(:finalize_deploy, true)
29
32
  finalize_update
30
33
  end
31
34
  end
32
-
35
+
33
36
  desc "Update the database (overwritten to avoid symlink)"
34
37
  task :migrations do
35
38
  transaction do
@@ -37,19 +40,19 @@ Capistrano::Configuration.instance(:must_exist).load do
37
40
  end
38
41
  migrate
39
42
  end
40
-
41
-
43
+
44
+
42
45
  # "rollback" is actually a namespace with a default task
43
46
  # we overwrite the default task below to get our new behavior
44
47
  namespace :rollback do
45
48
  desc "Moves the repo back to the previous version of HEAD"
46
- task :repo, :except => { :no_release => true }, :roles => [:app, :worker] do
49
+ task :repo, :except => { :no_release => true }, :roles => deploy_roles do
47
50
  set :branch, "HEAD@{1}"
48
51
  deploy.default
49
52
  end
50
53
 
51
54
  desc "Rewrite reflog so HEAD@{1} will continue to point to at the next previous release."
52
- task :cleanup, :except => { :no_release => true }, :roles => [:app, :worker] do
55
+ task :cleanup, :except => { :no_release => true }, :roles => deploy_roles do
53
56
  run "cd #{current_path}; git reflog delete --rewrite HEAD@{1}; git reflog delete --rewrite HEAD@{1}"
54
57
  end
55
58
 
@@ -59,16 +62,16 @@ Capistrano::Configuration.instance(:must_exist).load do
59
62
  rollback.cleanup
60
63
  end
61
64
  end
62
-
65
+
63
66
  end
64
-
67
+
65
68
  #############################################################
66
69
  # Set Rake Path
67
70
  #############################################################
68
71
 
69
72
  namespace :deploy do
70
73
  desc "Set rake path"
71
- task :set_rake_path, :roles => [:app, :worker] do
74
+ task :set_rake_path, :roles => deploy_roles do
72
75
  run "which rake" do |ch, stream, data|
73
76
  if stream == :err
74
77
  abort "captured output on STDERR when setting rake path: #{data}"
@@ -78,7 +81,7 @@ Capistrano::Configuration.instance(:must_exist).load do
78
81
  end
79
82
  end
80
83
  end
81
-
84
+
82
85
 
83
86
  # Turn of capistrano's restart in favor of passenger restart
84
87
  namespace :deploy do
@@ -86,5 +89,4 @@ Capistrano::Configuration.instance(:must_exist).load do
86
89
  task :restart do
87
90
  end
88
91
  end
89
-
90
92
  end
@@ -1,22 +1,24 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ _cset :db_migration_roles, [:db]
3
+
2
4
  namespace :deploy do
3
5
  desc <<-DESC
4
- Run the migrate rake task. By default, it runs this in most recently \
5
- deployed version of the app. However, you can specify a different release \
6
- via the migrate_target variable, which must be one of :latest (for the \
7
- default behavior), or :current (for the release indicated by the \
8
- `current' symlink). Strings will work for those values instead of symbols, \
9
- too. You can also specify additional environment variables to pass to rake \
10
- via the migrate_env variable. Finally, you can specify the full path to the \
6
+ Run the migrate rake task. By default, it runs this in most recently
7
+ deployed version of the app. However, you can specify a different release
8
+ via the migrate_target variable, which must be one of :latest (for the
9
+ default behavior), or :current (for the release indicated by the
10
+ `current' symlink). Strings will work for those values instead of symbols,
11
+ too. You can also specify additional environment variables to pass to rake
12
+ via the migrate_env variable. Finally, you can specify the full path to the
11
13
  rake executable by setting the rake variable. The defaults are:
12
14
 
13
- set :rake, "rake"
15
+ set :rake, "bundle exec rake"
14
16
  set :rails_env, "production"
15
17
  set :migrate_env, ""
16
18
  set :migrate_target, :latest
17
19
  DESC
18
- task :migrate, :roles => :worker, :only => { :primary => true } do
19
- rake = fetch(:rake, "rake")
20
+ task :migrate, :roles => db_migration_roles, :only => { :primary => true } do
21
+ rake = fetch(:rake, "bundle exec rake")
20
22
  rails_env = fetch(:rails_env, "production")
21
23
  migrate_env = fetch(:migrate_env, "")
22
24
  migrate_target = fetch(:migrate_target, :latest)
@@ -30,5 +32,4 @@ Capistrano::Configuration.instance(:must_exist).load do
30
32
  run "cd #{directory}; #{rake} RAILS_ENV=#{rails_env} #{migrate_env} db:migrate"
31
33
  end
32
34
  end #namespace
33
-
34
35
  end
@@ -1,4 +1,6 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ _cset :deployment_roles, [:app]
3
+
2
4
  # these are the usual suspects (for rails)
3
5
  set :standard_symlinks, {
4
6
  'log' => 'log',
@@ -6,33 +8,33 @@ Capistrano::Configuration.instance(:must_exist).load do
6
8
  'public/system' => 'system',
7
9
  'tmp' => 'tmp'
8
10
  }
9
-
11
+
10
12
  # these are project specific but still reside in shared
11
13
  # e.g., 'backups' => 'db/backups'
12
14
  # ==> rm -rf #{release_path}/backups && ln -s #{shared_path}/db/backups #{release_path}/backups
13
15
  _cset :custom_symlinks, {}
14
-
16
+
15
17
  # these are project specific but need full 'from' paths
16
18
  # eg 'foo' => '/var/www/apps/project/foo'
17
19
  # creates the command "rm -rf #{release_path}/foo && ln -s /var/www/apps/project/foo #{release_path}/foo"
18
20
  _cset :other_symlinks, {}
19
-
21
+
20
22
  namespace :symlinks do
21
23
  desc "Create all sylinks (removes directories/files if they exist first)"
22
- task :create, :roles => [:app, :worker], :except => { :no_release => true } do
23
-
24
+ task :create, :roles => deployment_roles, :except => { :no_release => true } do
25
+
24
26
  commands = standard_symlinks.map do |to, from|
25
27
  "rm -rf #{current_path}/#{to} && ln -s #{shared_path}/#{from} #{current_path}/#{to}"
26
28
  end
27
-
29
+
28
30
  commands += custom_symlinks.map do |to, from|
29
31
  "rm -rf #{current_path}/#{to} && ln -s #{shared_path}/#{from} #{current_path}/#{to}"
30
32
  end
31
-
33
+
32
34
  commands += other_symlinks.map do |to, from|
33
35
  "rm -rf #{current_path}/#{to} && ln -s #{from} #{current_path}/#{to}"
34
36
  end
35
-
37
+
36
38
  run "cd #{current_path} && #{commands.join(" && ")}"
37
39
  end
38
40
  end
@@ -0,0 +1,17 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do |configuration|
2
+ namespace :jekyll do
3
+ desc "Build static files from jekyll files"
4
+ task :build do
5
+ alert_user "Building static files from jekyll files"
6
+ run_locally "jekyll"
7
+ end
8
+
9
+ desc "Create site (less and jekyll)"
10
+ task :create do
11
+ alert_user "[START] Creating site [START]"
12
+ find_and_execute_task('less:build')
13
+ find_and_execute_task('jekyll:build')
14
+ alert_user "[END] Creating site [END]"
15
+ end
16
+ end
17
+ end
@@ -1,28 +1,30 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ _cset :passenger_roles, [:app]
3
+
2
4
  #############################################################
3
5
  # Passenger Restart
4
6
  #############################################################
5
7
 
6
8
  namespace :passenger do
7
9
  desc "Restart Application"
8
- task :restart, :except => { :no_release => true }, :roles => [:app] do
10
+ task :restart, :except => { :no_release => true }, :roles => passenger_roles do
9
11
  run "touch #{current_path}/tmp/restart.txt"
10
12
  end
11
13
  end
12
-
14
+
13
15
  #############################################################
14
16
  # Passenger Status Checks
15
17
  #############################################################
16
18
 
17
19
  namespace :passenger do
18
20
  desc "Check Passenger Status"
19
- task :status, :roles => [:app] do
21
+ task :status, :roles => passenger_roles do
20
22
  sudo 'passenger-status'
21
23
  end
22
24
 
23
25
  desc "Check Apache/Passenger Memory Usage"
24
- task :memory_stats, :roles => [:app] do
26
+ task :memory_stats, :roles => passenger_roles do
25
27
  sudo 'passenger-memory-stats'
26
28
  end
27
29
  end
28
- end
30
+ end
File without changes
@@ -1,12 +1,11 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
-
2
+ _cset :sass_roles, [:app]
3
+
4
+ #this is pre-asset pipeline days - left in for backwards compatibility
3
5
  namespace :sass do
4
-
5
6
  desc "Generate (force) the compiled CSS files from Sass"
6
- task :update_stylesheets, :roles => [:worker] do
7
+ task :update_stylesheets, :roles => sass_roles do
7
8
  run "cd #{current_path}; script/runner -e #{rails_env} 'Sass::Plugin.options[:always_update] = 1; Sass::Plugin.update_stylesheets'"
8
9
  end
9
-
10
- end # end namespace
11
-
10
+ end
12
11
  end
@@ -1,8 +1,9 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ _cset :site_roles, [:app]
2
3
 
3
4
  namespace :site do
4
5
  desc "Serve up a custom maintenance page."
5
- task :disable, :roles => [:app] do
6
+ task :disable, :roles => site_roles do
6
7
  require 'erb'
7
8
  on_rollback { delete "#{shared_path}/system/maintenance.html" }
8
9
  reason = ENV['REASON' ]
@@ -10,14 +11,13 @@ Capistrano::Configuration.instance(:must_exist).load do
10
11
 
11
12
  template = File.join(File.dirname(__FILE__), "..", "..", "..", "files", 'app', 'maintenance.html.erb')
12
13
  page = ERB.new(File.read(template)).result(binding)
13
-
14
+
14
15
  upload_string page, "#{shared_path}/system/maintenance.html", :via => :scp, :mode => 644
15
16
  end
16
-
17
- desc "Serve up a custom maintenance page."
18
- task :enable, :roles => :web do
17
+
18
+ desc "Remove custom maintenance page."
19
+ task :enable, :roles => site_roles do
19
20
  run "rm #{shared_path}/system/maintenance.html"
20
21
  end
21
- end #end namespace
22
-
23
- end
22
+ end
23
+ end
@@ -1,49 +1,56 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ _cset :thinking_sphinx_roles, [:app]
3
+
2
4
  namespace :thinking_sphinx do
3
-
4
5
  desc "Generate the Sphinx configuration file"
5
- task :configure, :roles => :worker do
6
+ task :configure, :roles => thinking_sphinx_roles do
6
7
  rake "thinking_sphinx:configure"
7
8
  end
8
-
9
+
9
10
  desc "Index data"
10
- task :index, :roles => :worker do
11
+ task :index, :roles => thinking_sphinx_roles do
11
12
  rake "thinking_sphinx:index"
12
13
  end
13
-
14
+
14
15
  desc "Start the Sphinx daemon"
15
- task :start, :roles => :worker do
16
- configure
16
+ task :start, :roles => thinking_sphinx_roles do
17
17
  rake "thinking_sphinx:start"
18
18
  end
19
-
19
+
20
20
  desc "Stop the Sphinx daemon"
21
- task :stop, :roles => :worker do
22
- configure
21
+ task :stop, :roles => thinking_sphinx_roles do
23
22
  rake "thinking_sphinx:stop"
24
23
  end
25
-
24
+
26
25
  desc "Stop and then start the Sphinx daemon"
27
- task :restart, :roles => :worker do
26
+ task :restart, :roles => thinking_sphinx_roles do
28
27
  stop
29
28
  start
30
29
  end
31
-
30
+
31
+ desc "Stop, configure, re-index and then start the Sphinx daemon"
32
+ task :rebuild, :roles => thinking_sphinx_roles do
33
+ stop
34
+ configure
35
+ index
36
+ start
37
+ end
38
+
32
39
  desc "Stop, re-index and then start the Sphinx daemon"
33
- task :rebuild, :roles => :worker do
40
+ task :reindex, :roles => thinking_sphinx_roles do
34
41
  stop
35
42
  index
36
43
  start
37
44
  end
38
-
45
+
39
46
  desc "Add the shared folder for sphinx files for the production environment"
40
- task :shared_sphinx_folder, :roles => [:app, :worker] do
47
+ task :create_shared_sphinx_folder, :roles => thinking_sphinx_roles do
41
48
  run "mkdir -p #{shared_path}/db/sphinx/production"
42
49
  end
43
50
 
44
51
  def rake(*tasks)
45
52
  rails_env = fetch(:rails_env, "production")
46
- rake = fetch(:rake, "rake")
53
+ rake = fetch(:rake, "bundle exec rake")
47
54
  tasks.each do |t|
48
55
  run "if [ -d #{release_path} ]; then cd #{release_path}; else cd #{current_path}; fi; #{rake} RAILS_ENV=#{rails_env} #{t}"
49
56
  end
File without changes
@@ -1,12 +1,10 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
-
2
+ _cset :varnish_roles, [:app]
3
+
3
4
  namespace :varnish do
4
-
5
- desc "Generate the compiled CSS files from Sass"
6
- task :clear_cache, :roles => [:proxy] do
5
+ desc "Clear the entire varnish cache ('.*')"
6
+ task :clear_cache, :roles => varnish_roles do
7
7
  sudo 'varnishadm -T localhost:6082 purge.url ".*"'
8
8
  end
9
-
10
- end # end namespace
11
-
12
- end
9
+ end
10
+ end
@@ -5,51 +5,18 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "thunder_punch"
8
- s.version = "0.0.14"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bob Burbach"]
12
- s.date = "2013-01-08"
12
+ s.date = "2014-07-30"
13
13
  s.description = "Collection of capistano recipes for deployment and server tasks"
14
14
  s.email = "info@criticaljuncture.org"
15
15
  s.extra_rdoc_files = [
16
16
  "README.mdown"
17
17
  ]
18
- s.files = [
19
- ".document",
20
- "CHANGELOG.mdown",
21
- "MIT-LICENSE",
22
- "Manifest",
23
- "README.mdown",
24
- "Rakefile",
25
- "TODO.mdown",
26
- "VERSION",
27
- "example/amazon.yml",
28
- "files/app/maintenance.html.erb",
29
- "lib/recipes.rb",
30
- "lib/recipes/bundler.rb",
31
- "lib/recipes/database.rb",
32
- "lib/recipes/deployment.rb",
33
- "lib/recipes/deployment/deployment.rb",
34
- "lib/recipes/deployment/migration.rb",
35
- "lib/recipes/deployment/passenger.rb",
36
- "lib/recipes/deployment/symlinks.rb",
37
- "lib/recipes/ec2.rb",
38
- "lib/recipes/ec2/ami.rb",
39
- "lib/recipes/jekyll/jekyll.rb",
40
- "lib/recipes/less/less.rb",
41
- "lib/recipes/sass.rb",
42
- "lib/recipes/sass/compile.rb",
43
- "lib/recipes/site.rb",
44
- "lib/recipes/thinking_sphinx.rb",
45
- "lib/recipes/varnish.rb",
46
- "lib/recipes/varnish/cache.rb",
47
- "lib/thunder_punch.rb",
48
- "lib/utilities/utilities.rb",
49
- "test/helper.rb",
50
- "test/test_thunder_punch.rb",
51
- "thunder_punch.gemspec"
52
- ]
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
53
20
  s.homepage = "http://github.com/critical/thunder_punch"
54
21
  s.require_paths = ["lib"]
55
22
  s.rubygems_version = "1.8.10"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thunder_punch
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 14
10
- version: 0.0.14
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bob Burbach
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-01-08 00:00:00 Z
18
+ date: 2014-07-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: thoughtbot-shoulda
@@ -57,6 +57,7 @@ extra_rdoc_files:
57
57
  - README.mdown
58
58
  files:
59
59
  - .document
60
+ - .gitignore
60
61
  - CHANGELOG.mdown
61
62
  - MIT-LICENSE
62
63
  - Manifest
@@ -66,26 +67,23 @@ files:
66
67
  - VERSION
67
68
  - example/amazon.yml
68
69
  - files/app/maintenance.html.erb
69
- - lib/recipes.rb
70
- - lib/recipes/bundler.rb
71
- - lib/recipes/database.rb
72
- - lib/recipes/deployment.rb
73
- - lib/recipes/deployment/deployment.rb
74
- - lib/recipes/deployment/migration.rb
75
- - lib/recipes/deployment/passenger.rb
76
- - lib/recipes/deployment/symlinks.rb
77
- - lib/recipes/ec2.rb
78
- - lib/recipes/ec2/ami.rb
79
- - lib/recipes/jekyll/jekyll.rb
80
- - lib/recipes/less/less.rb
81
- - lib/recipes/sass.rb
82
- - lib/recipes/sass/compile.rb
83
- - lib/recipes/site.rb
84
- - lib/recipes/thinking_sphinx.rb
85
- - lib/recipes/varnish.rb
86
- - lib/recipes/varnish/cache.rb
87
70
  - lib/thunder_punch.rb
88
- - lib/utilities/utilities.rb
71
+ - lib/thunder_punch/recipes.rb
72
+ - lib/thunder_punch/recipes/bundler.rb
73
+ - lib/thunder_punch/recipes/database.rb
74
+ - lib/thunder_punch/recipes/deployment.rb
75
+ - lib/thunder_punch/recipes/deployment/deployment.rb
76
+ - lib/thunder_punch/recipes/deployment/migration.rb
77
+ - lib/thunder_punch/recipes/deployment/symlinks.rb
78
+ - lib/thunder_punch/recipes/jekyll/jekyll.rb
79
+ - lib/thunder_punch/recipes/passenger.rb
80
+ - lib/thunder_punch/recipes/sass.rb
81
+ - lib/thunder_punch/recipes/sass/compile.rb
82
+ - lib/thunder_punch/recipes/site.rb
83
+ - lib/thunder_punch/recipes/thinking_sphinx.rb
84
+ - lib/thunder_punch/recipes/varnish.rb
85
+ - lib/thunder_punch/recipes/varnish/cache.rb
86
+ - lib/thunder_punch/utilities/utilities.rb
89
87
  - test/helper.rb
90
88
  - test/test_thunder_punch.rb
91
89
  - thunder_punch.gemspec
@@ -122,5 +120,6 @@ rubygems_version: 1.8.10
122
120
  signing_key:
123
121
  specification_version: 3
124
122
  summary: Collection of capistano recipes for deployment and server tasks
125
- test_files: []
126
-
123
+ test_files:
124
+ - test/helper.rb
125
+ - test/test_thunder_punch.rb
data/lib/recipes.rb DELETED
@@ -1,3 +0,0 @@
1
- Dir["#{File.dirname(__FILE__)}/recipes/*.rb"].each { |lib|
2
- Capistrano::Configuration.instance.load {load(lib)}
3
- }
@@ -1,12 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
-
3
- namespace :bundler do
4
- desc "Install and lock bundle"
5
- task :fix_bundle, :roles => [:app, :worker] do
6
- _cset(:gem_file_groups) { [:development, :production] }
7
- excluded_groups = gem_file_groups.reject{|e| e == rails_env.to_sym}.each{|g| g.to_s}.join(' ')
8
- run "cd #{current_path} && bundle install --deployment --without #{excluded_groups}"
9
- end
10
- end
11
-
12
- end
data/lib/recipes/ec2.rb DELETED
@@ -1,3 +0,0 @@
1
- Dir["#{File.dirname(__FILE__)}/ec2/*.rb"].each { |lib|
2
- Capistrano::Configuration.instance.load {load(lib)}
3
- }
@@ -1,102 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do |configuration|
2
-
3
- namespace :ec2 do
4
- _cset :ec2_config_loaded, false
5
- _cset :ec2_config_location, nil
6
-
7
- task :load_ec2_config, :roles => :app do
8
- alert_user('You need to set :ec2_config_location in your deploy file', :abort => true) unless ec2_config_location
9
- alert_user("You must configure your ec2 settings in config/amazon.yml", :abort => true) unless File.exist?(ec2_config_location)
10
-
11
- ec2_config = YAML.load( File.open(ec2_config_location, 'r') )
12
-
13
- set :aws_key_location, ec2_config['aws_key_location']
14
- set :ec2_private_key, ec2_config['ec2_private_key']
15
- set :ec2_x509_cert, ec2_config['ec2_x509_cert']
16
- set :aws_account_id, ec2_config['aws_account_id']
17
- set :ec2_architecture, ec2_config['ec2_architecture']
18
- set :access_key_id, ec2_config['access_key_id']
19
- set :secret_access_key, ec2_config['secret_access_key']
20
- set :ec2_s3_bucket_name, ec2_config['ec2_s3_bucket_name']
21
- set :ami_excluded_items, ec2_config['ami_excluded_items']
22
-
23
- alert_user('You need to set :aws_key_location in config/amazon.yml', :abort => true) unless :key_location
24
- alert_user('You need to set :ec2_private_key in config/amazon.yml', :abort => true) unless :ec2_private_key
25
- alert_user('You need to set :ec2_x509_cert in config/amazon.yml', :abort => true) unless :ec2_x509_cert
26
- alert_user('You need to set :aws_account_id in config/amazon.yml', :abort => true) unless :aws_account_id
27
- alert_user('You need to set :ec2_architecture to either "i386" or "x86_64" in config/amazon.yml', :abort => true) unless :ec2_architecture
28
- alert_user('You need to set :access_key_id in config/amazon.yml', :abort => true) unless :access_key_id
29
- alert_user('You need to set :secret_access_key in config/amazon.yml', :abort => true) unless :secret_access_key
30
- alert_user('You need to set :ec2_s3_bucket_name in config/amazon.yml', :abort => true) unless :ec2_s3_bucket_name
31
-
32
- set :ec2_config_loaded, true
33
- end
34
-
35
- desc 'Bundle new AMI, upload to S3, and register'
36
- task :create_new_ami, :roles => :app do
37
- load_ec2_config unless ec2_config_loaded
38
-
39
- should_copy_keys = Capistrano::CLI.ui.ask "Do you need to copy your keys to the ec2 instance you are creating an AMI from? [Y/n]: "
40
- while !['Y', 'n'].include?(should_copy_keys)
41
- puts "\n Please choose Y or n \n"
42
- should_copy_keys = Capistrano::CLI.ui.ask "Do you need to copy your keys? [Y/n]: "
43
- end
44
- copy_keys unless should_copy_keys == 'n'
45
-
46
- alert_user("You need to set :bundle_name via the command line\n `cap ec2:create_new_ami -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
47
- bundle_ami
48
- upload_ami_to_s3
49
- register_ami
50
- end
51
-
52
- desc 'Copy private key and X.509 certificate to server'
53
- task :copy_keys, :roles => :app do
54
- load_ec2_config unless ec2_config_loaded
55
-
56
- alert_user("Ensure you have owner:group set properly on your EC2 /mnt directory or scp will fail!")
57
-
58
- upload "#{aws_key_location}/#{ec2_private_key}", "/mnt/", :via => :scp
59
- upload "#{aws_key_location}/#{ec2_x509_cert}", "/mnt/", :via => :scp
60
- end
61
-
62
- desc 'Bundle your AMI (including fstab)'
63
- task :bundle_ami, :roles => :app do
64
- load_ec2_config unless ec2_config_loaded
65
- alert_user("You need to set :bundle_name via the command line\n `cap ec2:bundle_ami -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
66
- default_ami_excluded_items = ['/sys/kernel/debug',
67
- '/sys/kernel/security',
68
- '/sys',
69
- '/proc',
70
- '/sys/fs/fuse/connections',
71
- '/dev/pts',
72
- '/dev',
73
- '/media',
74
- '/mnt',
75
- '/proc',
76
- '/sys',
77
- '/etc/udev/rules.d/70-persistent-net.rules',
78
- '/etc/udev/rules.d/z25_persistent-net.rules',
79
- "/mnt/#{bundle_name}",
80
- '/mnt/img-mnt']
81
-
82
- sudo "ec2-bundle-vol -d /mnt --fstab /etc/fstab -k /mnt/#{ec2_private_key} -c /mnt/#{ec2_x509_cert} -u #{aws_account_id} -r #{ec2_architecture} -p #{bundle_name} --all --exclude #{(ami_excluded_items | default_ami_excluded_items).join(', ')}"
83
- end
84
-
85
- desc 'Upload your bundled AMI to S3'
86
- task :upload_ami_to_s3, :roles => :app do
87
- load_ec2_config unless ec2_config_loaded
88
- alert_user("You need to set :bundle_name via the command line\n `cap ec2:upload_to_s3 -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
89
- sudo "ec2-upload-bundle -b #{ec2_s3_bucket_name} -m /mnt/#{bundle_name}.manifest.xml -a #{access_key_id} -s #{secret_access_key}"
90
- end
91
-
92
- desc 'Register your bundled and upload (to S3) AMI'
93
- task :register_ami, :roles => :app do
94
- load_ec2_config unless ec2_config_loaded
95
- alert_user("You need to set :bundle_name via the command line\n `cap ec2:register_ami -s bundle_name=sample`", :abort => true) unless configuration[:bundle_name]
96
- ami_description = Capistrano::CLI.ui.ask "Description [enter for none]: "
97
- run_locally "ec2-register #{ec2_s3_bucket_name}/#{bundle_name}.manifest.xml -n #{bundle_name} -a #{ec2_architecture} -d #{ami_description.dump}"
98
- end
99
-
100
- end
101
-
102
- end
@@ -1,19 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do |configuration|
2
-
3
- namespace :jekyll do
4
- desc "Build static files from jekyll files"
5
- task :build do
6
- alert_user "Building static files from jekyll files"
7
- run_locally "jekyll"
8
- end
9
-
10
- desc "Create site (less and jekyll)"
11
- task :create do
12
- alert_user "[START] Creating site [START]"
13
- find_and_execute_task('less:build')
14
- find_and_execute_task('jekyll:build')
15
- alert_user "[END] Creating site [END]"
16
- end
17
- end
18
-
19
- end
@@ -1,18 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do |configuration|
2
-
3
- namespace :less do
4
- desc "Build css files from .less files"
5
- task :build do
6
- _cset :less_directory, '_less'
7
- _cset :css_directory, 'css'
8
- Dir.glob(less_directory + '/*.less').each do |file|
9
- if File.file?(file)
10
- file_name = file.split('/').last.split('.').first
11
- alert_user("Creating css file for less file named #{file_name}" )
12
- run_locally("lessc #{less_directory}/#{file_name}.less #{css_directory}/#{file_name}.css")
13
- end
14
- end
15
- end
16
- end
17
-
18
- end