nesquena-cap-recipes 0.1.5
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 +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +28 -0
- data/README.txt +95 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/lib/cap_recipes.rb +1 -0
- data/lib/cap_recipes/tasks/apache.rb +38 -0
- data/lib/cap_recipes/tasks/backgroundrb.rb +75 -0
- data/lib/cap_recipes/tasks/juggernaut.rb +47 -0
- data/lib/cap_recipes/tasks/passenger.rb +94 -0
- data/lib/cap_recipes/version.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_cap_recipes.rb +11 -0
- data/test/test_helper.rb +2 -0
- data/website/index.html +141 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +87 -0
data/History.txt
ADDED
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,28 @@
|
|
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
|
+
tasks/development.rake
|
20
|
+
tasks/environment.rake
|
21
|
+
tasks/website.rake
|
22
|
+
test/test_cap_recipes.rb
|
23
|
+
test/test_helper.rb
|
24
|
+
website/index.html
|
25
|
+
website/index.txt
|
26
|
+
website/javascripts/rounded_corners_lite.inc.js
|
27
|
+
website/stylesheets/screen.css
|
28
|
+
website/template.html.erb
|
data/README.txt
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
= cap_recipes
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
This is a collection of capistrano recipes which will grow to encompass many useful recipes. Currently included:
|
6
|
+
|
7
|
+
* Phusion Passenger (Setup and Deployment)
|
8
|
+
* Apache Server
|
9
|
+
* Juggernaut Process
|
10
|
+
* Backgroundrb Processes
|
11
|
+
|
12
|
+
== SYNOPSIS:
|
13
|
+
|
14
|
+
To include any of these into your deploy.rb configuration file for Capistrano:
|
15
|
+
|
16
|
+
require 'cap_recipes/tasks/passenger'
|
17
|
+
require 'cap_recipes/tasks/apache'
|
18
|
+
require 'cap_recipes/tasks/backgroundrb'
|
19
|
+
require 'cap_recipes/tasks/juggernaut'
|
20
|
+
|
21
|
+
== USAGE
|
22
|
+
|
23
|
+
Passenger
|
24
|
+
|
25
|
+
deploy
|
26
|
+
:stop
|
27
|
+
:start
|
28
|
+
:restart
|
29
|
+
:with_migrations
|
30
|
+
:copy_config
|
31
|
+
:tail
|
32
|
+
:install
|
33
|
+
sweep
|
34
|
+
:cache
|
35
|
+
:log
|
36
|
+
|
37
|
+
Apache
|
38
|
+
variables: apache_init_path
|
39
|
+
tasks:
|
40
|
+
apache
|
41
|
+
:stop
|
42
|
+
:start
|
43
|
+
:restart
|
44
|
+
:install
|
45
|
+
|
46
|
+
Backgroundrb
|
47
|
+
variables: backgroundrb_log
|
48
|
+
tasks:
|
49
|
+
backgroundrb
|
50
|
+
:stop
|
51
|
+
:start
|
52
|
+
:restart
|
53
|
+
:copy_config
|
54
|
+
:tail
|
55
|
+
|
56
|
+
Juggernaut
|
57
|
+
|
58
|
+
variables: juggernaut_config, juggernaut_pid, juggernaut_log
|
59
|
+
tasks:
|
60
|
+
juggernaut
|
61
|
+
:start
|
62
|
+
:stop
|
63
|
+
:restart
|
64
|
+
:copy_config
|
65
|
+
:tail
|
66
|
+
|
67
|
+
== INSTALL:
|
68
|
+
|
69
|
+
* gem sources -a http://gems.github.com/
|
70
|
+
* sudo gem install xgamerx-cap-recipes
|
71
|
+
|
72
|
+
== LICENSE:
|
73
|
+
|
74
|
+
(The MIT License)
|
75
|
+
|
76
|
+
Copyright (c) 2008 Nathan Esquenazi
|
77
|
+
|
78
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
79
|
+
a copy of this software and associated documentation files (the
|
80
|
+
'Software'), to deal in the Software without restriction, including
|
81
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
82
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
83
|
+
permit persons to whom the Software is furnished to do so, subject to
|
84
|
+
the following conditions:
|
85
|
+
|
86
|
+
The above copyright notice and this permission notice shall be
|
87
|
+
included in all copies or substantial portions of the Software.
|
88
|
+
|
89
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
90
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
91
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
92
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
93
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
94
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
95
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
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]))
|
data/lib/cap_recipes.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'cap_recipes/**/*.rb')].sort.each { |lib| require lib }
|
@@ -0,0 +1,38 @@
|
|
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
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
4
|
+
set :backgroundrb_host, 'localhost'
|
5
|
+
set :backgroundrb_env , 'production'
|
6
|
+
|
7
|
+
namespace :backgroundrb do
|
8
|
+
# ===============================================================
|
9
|
+
# PROCESS MANAGEMENT
|
10
|
+
# ===============================================================
|
11
|
+
|
12
|
+
desc "Stops the backgroundrb worker processes"
|
13
|
+
task :stop, :role => :app do
|
14
|
+
run "cd #{current_path} && #{sudo} ruby script/backgroundrb stop -e #{backgroundrb_env}"
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Starts the backgroundrb worker processes"
|
18
|
+
task :start, :role => :app do
|
19
|
+
run "cd #{current_path} && #{sudo} nohup ruby script/backgroundrb start -e #{backgroundrb_env}"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Restarts a running backgroundrb server."
|
23
|
+
task :restart, :role => :app do
|
24
|
+
backgroundrb.stop
|
25
|
+
sleep(5) # sleep for 5 seconds to make sure the server has mopped up everything
|
26
|
+
backgroundrb.start
|
27
|
+
end
|
28
|
+
|
29
|
+
# ===============================================================
|
30
|
+
# PROCESS CONFIGURATION
|
31
|
+
# ===============================================================
|
32
|
+
|
33
|
+
desc "Creates configuration file for the backgroundrb server"
|
34
|
+
task :configure, :role => :app do
|
35
|
+
config = { :backgroundrb => {:ip => backgroundrb_host, :port => backgroundrb_port, :environment => backgroundrb_env} }
|
36
|
+
backgroundrb_yml = config.to_yaml
|
37
|
+
|
38
|
+
run "if [ ! -d #{shared_path}/config ]; then mkdir #{shared_path}/config; fi"
|
39
|
+
put(backgroundrb_yml, "#{shared_path}/config/backgroundrb.yml", :mode => 0644)
|
40
|
+
end
|
41
|
+
|
42
|
+
# ===============================================================
|
43
|
+
# FILE MANAGEMENT
|
44
|
+
# ===============================================================
|
45
|
+
|
46
|
+
desc "Copies the shared/config/backgroundrb yaml to release/config/"
|
47
|
+
task :copy_config, :role => :app do
|
48
|
+
on_rollback {
|
49
|
+
puts "***** File shared/config/backgroundrb.yml is missing. Make sure you have run backgroundrb:configure first. *****"
|
50
|
+
}
|
51
|
+
|
52
|
+
run "cp #{shared_path}/config/backgroundrb.yml #{release_path}/config/"
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Displays the backgroundrb log from the server"
|
56
|
+
task :tail do
|
57
|
+
stream "tail -f #{shared_path}/log/backgroundrb_#{backgroundrb_port}.log"
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Repair permissions to allow user to perform all actions"
|
61
|
+
task :repair_permissions, :role => :app do
|
62
|
+
puts "Applying correct permissions to allow for proper command execution"
|
63
|
+
sudo "chown -R #{user}:#{user} #{current_path}"
|
64
|
+
sudo "chown -R #{user}:#{user} #{current_path}/tmp"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# ===============================================================
|
69
|
+
# TASK CALLBACKS
|
70
|
+
# ===============================================================
|
71
|
+
|
72
|
+
after "deploy:update_code" , "backgroundrb:copy_config"
|
73
|
+
after "deploy:restart" , "backgroundrb:restart"
|
74
|
+
after "backgroundrb:restart" , "backgroundrb:repair_permissions"
|
75
|
+
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 "#{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 "#{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, :role => :app 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,94 @@
|
|
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 "Repair permissions to allow user to perform all actions"
|
49
|
+
task :repair_permissions, :role => :app do
|
50
|
+
puts "Applying correct permissions to allow for proper command execution"
|
51
|
+
sudo "chmod -R 744 #{current_path}/log #{current_path}/tmp"
|
52
|
+
sudo "chown -R #{user}:#{user} #{current_path}"
|
53
|
+
sudo "chown -R #{user}:#{user} #{current_path}/tmp"
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Displays the production log from the server locally"
|
57
|
+
task :tail, :role => :app do
|
58
|
+
stream "tail -f #{shared_path}/log/production.log"
|
59
|
+
end
|
60
|
+
|
61
|
+
# ===============================================================
|
62
|
+
# INSTALLATION
|
63
|
+
# ===============================================================
|
64
|
+
|
65
|
+
task :install, :role => :app do
|
66
|
+
puts 'Installing passenger gems'
|
67
|
+
sudo 'gem install fastthread passenger'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# ===============================================================
|
72
|
+
# MAINTENANCE TASKS
|
73
|
+
# ===============================================================
|
74
|
+
namespace :sweep do
|
75
|
+
desc "Clear file-based fragment and action caching"
|
76
|
+
task :log, :role => :app do
|
77
|
+
puts "Sweeping all the log files"
|
78
|
+
run "cd #{current_path} && #{sudo} rake log:clear RAILS_ENV=production"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Clear file-based fragment and action caching"
|
82
|
+
task :cache, :role => :app do
|
83
|
+
puts "Sweeping the fragment and action cache stores"
|
84
|
+
run "cd #{release_path} && #{sudo} rake tmp:cache:clear RAILS_ENV=production"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# ===============================================================
|
89
|
+
# TASK CALLBACKS
|
90
|
+
# ===============================================================
|
91
|
+
after "deploy:update_code", "deploy:copy_config" # copy database.yml file to release path
|
92
|
+
after "deploy:update_code", "sweep:cache" # clear cache after updating code
|
93
|
+
after "deploy:restart" , "deploy:repair_permissions" # fix the permissions to work properly
|
94
|
+
end
|