xgamerx-cap-recipes 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-04-26
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 FIXME full name
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,25 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ lib/cap_recipes.rb
9
+ lib/cap_recipes/version.rb
10
+ lib/cap_recipes/tasks/apache.rb
11
+ lib/cap_recipes/tasks/backgroundrb.rb
12
+ lib/cap_recipes/tasks/juggernaut.rb
13
+ lib/cap_recipes/tasks/passenger.rb
14
+ script/console
15
+ script/destroy
16
+ script/generate
17
+ script/txt2html
18
+ setup.rb
19
+ test/test_cap_recipes.rb
20
+ test/test_helper.rb
21
+ website/index.html
22
+ website/index.txt
23
+ website/javascripts/rounded_corners_lite.inc.js
24
+ website/stylesheets/screen.css
25
+ website/template.html.erb
data/README.txt ADDED
@@ -0,0 +1,48 @@
1
+ = cap_recipes
2
+
3
+ * FIX (url)
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * FIX (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ * FIX (sudo gem install, anything else)
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2008 FIX
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/config/hoe.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'cap_recipes/version'
2
+
3
+ AUTHOR = 'Nathan Esquenazi' # can also be an array of Authors
4
+ EMAIL = "xgamerx10@gmail.com"
5
+ DESCRIPTION = "My collection of capistrano recipes"
6
+ GEM_NAME = 'cap-recipes' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'caprecipes' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ ['capistrano', '>= 2.2.0']
12
+ ]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "nesquena"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = CapRecipes::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'cap_recipes documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/**/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
@@ -0,0 +1 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'cap_recipes/**/*.rb')].sort.each { |lib| require lib }
@@ -0,0 +1,39 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ set :apache_init_path, "/etc/init.d/apache2"
4
+
5
+ # ===============================================================
6
+ # SERVER MANAGEMENT
7
+ # ===============================================================
8
+
9
+ namespace :apache do
10
+ desc "Stops the apache web server"
11
+ task :stop, :role => :app do
12
+ puts "Stopping the apache server"
13
+ sudo "#{apache_init_path} stop"
14
+ end
15
+
16
+ desc "Starts the apache web server"
17
+ task :start, :role => :app do
18
+ puts "Starting the apache server"
19
+ sudo "#{apache_init_path} start"
20
+ end
21
+
22
+ desc "Restarts the apache web server"
23
+ task :restart, :role => :app do
24
+ puts "Restarting the apache server"
25
+ sudo "#{apache_init_path} restart"
26
+ end
27
+
28
+ # ===============================================================
29
+ # INSTALLATION
30
+ # ===============================================================
31
+
32
+ desc 'Installs apache 2 and development headers to compile passenger'
33
+ task :install, :roles => :web do
34
+ puts 'Installing apache 2'
35
+ sudo 'apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapr1 libapr1-dev libaprutil1 libmagic1 libpcre3 libpq5 openssl apache2-prefork-dev -y'
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,68 @@
1
+ require 'yaml'
2
+
3
+ Capistrano::Configuration.instance(true).load do
4
+ set :backgroundrb_log, "log/backgroundrb-cap.log"
5
+ set :backgroundrb_host, 'localhost'
6
+ set :backgroundrb_env, 'production'
7
+
8
+ namespace :backgroundrb do
9
+ # ===============================================================
10
+ # PROCESS MANAGEMENT
11
+ # ===============================================================
12
+
13
+ desc "Stops the backgroundrb worker processes"
14
+ task :stop, :role => :app do
15
+ run "cd #{current_path} && sudo ruby script/backgroundrb stop -e #{backgroundrb_env}"
16
+ end
17
+
18
+ desc "Starts the backgroundrb worker processes"
19
+ task :start, :role => :app do
20
+ run "cd #{current_path} && nohup ruby script/backgroundrb start -e #{backgroundrb_env} > #{backgroundrb_log}"
21
+ end
22
+
23
+ desc "Restarts a running backgroundrb server."
24
+ task :restart, :role => :app do
25
+ backgroundrb.stop
26
+ sleep(5) # sleep for 5 seconds to make sure the server has mopped up everything
27
+ backgroundrb.start
28
+ end
29
+
30
+ # ===============================================================
31
+ # PROCESS CONFIGURATION
32
+ # ===============================================================
33
+
34
+ desc "Creates configuration file for the backgroundrb server"
35
+ task :configure, :role => :app do
36
+ config = { :backgroundrb => {:ip => backgroundrb_host, :port => backgroundrb_port, :environment => backgroundrb_env} }
37
+ backgroundrb_yml = config.to_yaml
38
+
39
+ run "if [ ! -d #{shared_path}/config ]; then mkdir #{shared_path}/config; fi"
40
+ put(backgroundrb_yml, "#{shared_path}/config/backgroundrb.yml", :mode => 0644)
41
+ end
42
+
43
+ # ===============================================================
44
+ # FILE MANAGEMENT
45
+ # ===============================================================
46
+
47
+ desc "Copies the shared/config/backgroundrb yaml to release/config/"
48
+ task :copy_config, :role => :app do
49
+ on_rollback {
50
+ puts "***** File shared/config/backgroundrb.yml is missing. Make sure you have run backgroundrb:configure first. *****"
51
+ }
52
+
53
+ run "cp #{shared_path}/config/backgroundrb.yml #{release_path}/config/"
54
+ end
55
+
56
+ desc "Displays the backgroundrb log from the server"
57
+ task :tail do
58
+ stream "tail -f #{shared_path}/log/backgroundrb_#{backgroundrb_port}.log"
59
+ end
60
+ end
61
+
62
+ # ===============================================================
63
+ # TASK CALLBACKS
64
+ # ===============================================================
65
+
66
+ after "deploy:update_code", "backgroundrb:copy_config"
67
+ after "deploy:restart", "backgroundrb:restart"
68
+ end
@@ -0,0 +1,47 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ namespace :juggernaut do
4
+ # ===============================================================
5
+ # PROCESS MANAGEMENT
6
+ # ===============================================================
7
+
8
+ desc "Starts the juggernaut push server"
9
+ task :start, :role => :app do
10
+ puts "Starting juggernaut push server"
11
+ sudo "juggernaut -c #{juggernaut_config} -d --pid #{juggernaut_pid} --log #{juggernaut_log}"
12
+ end
13
+
14
+ desc "Stops the juggernaut push server"
15
+ task :stop, :role => :app do
16
+ puts "Stopping juggernaut push server"
17
+ sudo "juggernaut -c #{juggernaut_config} -k * --pid #{juggernaut_pid} --log #{juggernaut_log}"
18
+ end
19
+
20
+ desc "Restarts the juggernaut push server"
21
+ task :restart, :role => :app do
22
+ juggernaut.stop
23
+ juggernaut.start
24
+ end
25
+
26
+ # ===============================================================
27
+ # FILE MANAGEMENT
28
+ # ===============================================================
29
+
30
+ desc "Copies the shared/config/juggernaut yaml to release/config/"
31
+ task :copy_config, :role => :app do
32
+ sudo "cp #{shared_path}/config/juggernaut.yml #{release_path}/config/"
33
+ end
34
+
35
+ desc "Displays the juggernaut log from the server"
36
+ task :tail do
37
+ stream "tail -f #{shared_path}/log/juggernaut.log"
38
+ end
39
+ end
40
+
41
+ # ===============================================================
42
+ # TASK CALLBACKS
43
+ # ===============================================================
44
+
45
+ after "deploy:update_code", "juggernaut:copy_config" # copy juggernaut.yml on update code
46
+ after "deploy:restart" , "juggernaut:restart" # restart juggernaut on app restart
47
+ end
@@ -0,0 +1,86 @@
1
+ Capistrano::Configuration.instance(true).load do
2
+
3
+ # ===============================================================
4
+ # DEPLOYMENT SCRIPTS
5
+ # ===============================================================
6
+
7
+ namespace :deploy do
8
+
9
+ # ===============================================================
10
+ # SERVER MANAGEMENT
11
+ # ===============================================================
12
+
13
+ desc "Stops the phusion passenger server"
14
+ task :stop, :role => :app do
15
+ puts "Stopping rails web server"
16
+ apache.stop
17
+ end
18
+
19
+ desc "Starts the phusion passenger server"
20
+ task :start, :role => :app do
21
+ puts "Starting rails web server"
22
+ apache.start
23
+ end
24
+
25
+ desc "Restarts the phusion passenger server"
26
+ task :restart, :role => :app do
27
+ puts "Restarting the application"
28
+ run "touch #{current_path}/tmp/restart.txt"
29
+ end
30
+
31
+ desc "Update code on server, apply migrations, and restart passenger server"
32
+ task :with_migrations, :role => :app do
33
+ deploy.update
34
+ deploy.migrate
35
+ deploy.restart
36
+ end
37
+
38
+ # ===============================================================
39
+ # UTILITY TASKS
40
+ # ===============================================================
41
+
42
+ desc "Copies the shared/config/database yaml to release/config/"
43
+ task :copy_config, :role => :app do
44
+ puts "Copying database configuration to release path"
45
+ sudo "cp #{shared_path}/config/database.yml #{release_path}/config/"
46
+ end
47
+
48
+ desc "Displays the production log from the server locally"
49
+ task :tail, :role => :app do
50
+ stream "tail -f #{shared_path}/log/production.log"
51
+ end
52
+
53
+ # ===============================================================
54
+ # INSTALLATION
55
+ # ===============================================================
56
+
57
+ task :install, :role => :app do
58
+ puts 'Installing passenger gems'
59
+ sudo 'gem install fastthread passenger'
60
+ end
61
+ end
62
+
63
+ # ===============================================================
64
+ # MAINTENANCE TASKS
65
+ # ===============================================================
66
+ namespace :sweep do
67
+ desc "Clear file-based fragment and action caching"
68
+ task :log do
69
+ puts "Sweeping all the log files"
70
+ run "cd #{current_path} && sudo rake log:clear RAILS_ENV=production"
71
+ end
72
+
73
+ desc "Clear file-based fragment and action caching"
74
+ task :cache do
75
+ puts "Sweeping the fragment and action cache stores"
76
+ run "cd #{current_path} && rake tmp:cache:clear RAILS_ENV=production"
77
+ end
78
+ end
79
+
80
+ # ===============================================================
81
+ # TASK CALLBACKS
82
+ # ===============================================================
83
+
84
+ after "deploy:update_code", "deploy:copy_config" # copy database.yml file to release path
85
+ after "deploy:update_code", "sweep:cache" # clear cache after updating code
86
+ end