slingshot 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/License.txt +34 -0
- data/Manifest.txt +19 -0
- data/README.txt +17 -0
- data/Rakefile +123 -0
- data/lib/slingshot/gem_cap_plugin.rb +97 -0
- data/lib/slingshot/recipes.rb +230 -0
- data/lib/slingshot/server_setup.rb +545 -0
- data/lib/slingshot/version.rb +9 -0
- data/lib/slingshot.rb +10 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- data/test/test_helper.rb +3 -0
- data/test/test_slingshot.rb +11 -0
- data/website/index.html +184 -0
- data/website/index.txt +106 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +132 -0
- data/website/template.rhtml +49 -0
- metadata +70 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Copyright (c) 2007 Charles Brian Quinn, Highgroove Studios
|
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.
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
Includes Capistrano extensions and Gem Plugin to capistrano to allow
|
25
|
+
gem installation and selection
|
26
|
+
|
27
|
+
Specifically makes use of the Gem plugin with modifications.
|
28
|
+
|
29
|
+
---
|
30
|
+
Capistrano library to install and manage Ruby Gems
|
31
|
+
|
32
|
+
Copyright (c) 2006 Neil Wilson, Aldur Systems Ltd
|
33
|
+
|
34
|
+
Licensed under the GNU Public License v2. No warranty is provided.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
lib/slingshot.rb
|
7
|
+
lib/slingshot/version.rb
|
8
|
+
lib/slingshot/recipes.rb
|
9
|
+
lib/slingshot/server_setup.rb
|
10
|
+
lib/slingshot/gem_cap_plugin.rb
|
11
|
+
scripts/txt2html
|
12
|
+
setup.rb
|
13
|
+
test/test_helper.rb
|
14
|
+
test/test_slingshot.rb
|
15
|
+
website/index.html
|
16
|
+
website/index.txt
|
17
|
+
website/javascripts/rounded_corners_lite.inc.js
|
18
|
+
website/stylesheets/screen.css
|
19
|
+
website/template.rhtml
|
data/README.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
README for slingshot
|
2
|
+
====================
|
3
|
+
|
4
|
+
Slingshot is a set of server tasks for setting up a Slingshot Server.
|
5
|
+
|
6
|
+
Created by the good folks at Highgroove Studios and Slingshot Hosting.
|
7
|
+
|
8
|
+
For the latest, see: http://slingshot.rubyforge.org/
|
9
|
+
|
10
|
+
|
11
|
+
Contributors
|
12
|
+
====================
|
13
|
+
Charles Brian Quinn <cbq@highgroove.com>
|
14
|
+
Derek Haynes <derek.haynes@highgroove.com>
|
15
|
+
James Edward Gray II <james@highgroove.com>
|
16
|
+
Andre Lewis <andre@earthcode.com> - testing, improvements, bugfixes
|
17
|
+
Neil Wilson - original capistrano "Gem" plugin to install default gems
|
data/Rakefile
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
require 'hoe'
|
11
|
+
|
12
|
+
include FileUtils
|
13
|
+
require File.join(File.dirname(__FILE__), 'lib', 'slingshot', 'version')
|
14
|
+
|
15
|
+
AUTHOR = 'Charles Brian Quinn'
|
16
|
+
EMAIL = "cbq@slingshothosting.com"
|
17
|
+
DESCRIPTION = "Set of server setup tasks for use with Slingshot Hosting"
|
18
|
+
GEM_NAME = 'slingshot'
|
19
|
+
|
20
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
21
|
+
@config = nil
|
22
|
+
def rubyforge_username
|
23
|
+
unless @config
|
24
|
+
begin
|
25
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
26
|
+
rescue
|
27
|
+
puts <<-EOS
|
28
|
+
ERROR: No rubyforge config file found: #{@config_file}"
|
29
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
30
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
31
|
+
EOS
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
@rubyforge_username ||= @config["username"]
|
36
|
+
end
|
37
|
+
|
38
|
+
RUBYFORGE_PROJECT = 'slingshot' # The unix name for your project
|
39
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
40
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
41
|
+
|
42
|
+
NAME = "slingshot"
|
43
|
+
REV = nil
|
44
|
+
# UNCOMMENT IF REQUIRED:
|
45
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
46
|
+
VERS = Slingshot::VERSION::STRING + (REV ? ".#{REV}" : "")
|
47
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
|
48
|
+
RDOC_OPTS = ['--quiet', '--title', 'slingshot documentation',
|
49
|
+
"--opname", "index.html",
|
50
|
+
"--line-numbers",
|
51
|
+
"--main", "README",
|
52
|
+
"--inline-source"]
|
53
|
+
|
54
|
+
class Hoe
|
55
|
+
def extra_deps
|
56
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Generate all the Rake tasks
|
61
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
62
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
63
|
+
p.author = AUTHOR
|
64
|
+
p.description = DESCRIPTION
|
65
|
+
p.email = EMAIL
|
66
|
+
p.summary = DESCRIPTION
|
67
|
+
p.url = HOMEPATH
|
68
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
69
|
+
p.test_globs = ["test/**/test_*.rb"]
|
70
|
+
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
|
71
|
+
|
72
|
+
# == Optional
|
73
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
74
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
75
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
76
|
+
end
|
77
|
+
|
78
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
|
79
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
80
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
81
|
+
|
82
|
+
desc 'Generate website files'
|
83
|
+
task :website_generate do
|
84
|
+
Dir['website/**/*.txt'].each do |txt|
|
85
|
+
sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'Upload website files to rubyforge'
|
90
|
+
task :website_upload do
|
91
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
92
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
93
|
+
local_dir = 'website'
|
94
|
+
sh %{rsync -av #{local_dir}/ #{host}:#{remote_dir}}
|
95
|
+
end
|
96
|
+
|
97
|
+
desc 'Generate and upload website files'
|
98
|
+
task :website => [:website_generate, :website_upload]
|
99
|
+
|
100
|
+
desc 'Release the website and new gem version'
|
101
|
+
task :deploy => [:check_version, :website, :release] do
|
102
|
+
puts "Remember to create SVN tag:"
|
103
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
104
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
105
|
+
puts "Suggested comment:"
|
106
|
+
puts "Tagging release #{CHANGES}"
|
107
|
+
end
|
108
|
+
|
109
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
110
|
+
task :local_deploy => [:website_generate, :install_gem]
|
111
|
+
|
112
|
+
task :check_version do
|
113
|
+
unless ENV['VERSION']
|
114
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
115
|
+
exit
|
116
|
+
end
|
117
|
+
unless ENV['VERSION'] == VERS
|
118
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
119
|
+
exit
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# Capistrano library to install and manage Ruby Gems.
|
2
|
+
#
|
3
|
+
# ----
|
4
|
+
# Copyright (c) 2006 Neil Wilson, Aldur Systems Ltd
|
5
|
+
#
|
6
|
+
# Licensed under the GNU Public License v2. No warranty is provided.
|
7
|
+
#
|
8
|
+
# Modified by Charles Brian Quinn cbq@highgroove.com
|
9
|
+
#
|
10
|
+
require 'rubygems'
|
11
|
+
require 'capistrano'
|
12
|
+
# Installs within Capistrano as the plugin _gem_.
|
13
|
+
# Prefix all calls to the library with <tt>gem.</tt>
|
14
|
+
# Manages installing gems and versioned gems.
|
15
|
+
module Gem
|
16
|
+
|
17
|
+
# Default install command
|
18
|
+
#
|
19
|
+
# * doesn't install documentation
|
20
|
+
# * installs all required dependencies automatically.
|
21
|
+
#
|
22
|
+
GEM_INSTALL="gem install -y --no-rdoc"
|
23
|
+
|
24
|
+
# Upgrade the *gem* system to the latest version. Runs via *sudo*
|
25
|
+
def update_system
|
26
|
+
sudo "gem update --system"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Updates all the installed gems to the latest version. Runs via *sudo*.
|
30
|
+
# Don't use this command if any of the gems require a version selection.
|
31
|
+
def upgrade
|
32
|
+
sudo "gem update --no-rdoc"
|
33
|
+
end
|
34
|
+
|
35
|
+
# Removes old versions of gems from installation area.
|
36
|
+
def cleanup
|
37
|
+
sudo "gem cleanup"
|
38
|
+
end
|
39
|
+
|
40
|
+
# Installs the gems detailed in +packages+, selecting version +version+ if
|
41
|
+
# specified.
|
42
|
+
#
|
43
|
+
# +packages+ can be a single string or an array of strings.
|
44
|
+
#
|
45
|
+
# def install(packages, source=nil, version=nil)
|
46
|
+
def install(packages, options={})
|
47
|
+
sudo "#{GEM_INSTALL} #{options[:version] ? '-v '+options[:version].to_s : nil} " +
|
48
|
+
"#{options[:source] ? '--source='+options[:source] : nil } " +
|
49
|
+
"#{packages.to_a.join(' ')}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def uninstall(package)
|
53
|
+
sudo "gem uninstall #{package}" do |channel, stream, data|
|
54
|
+
data.each_line do |line|
|
55
|
+
if line =~ /\[Yn\]/
|
56
|
+
channel.send_data "Y\n"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Auto selects a gem from a list and installs it.
|
63
|
+
#
|
64
|
+
# *gem* has no mechanism on the command line of disambiguating builds for
|
65
|
+
# different platforms, and instead asks the user. This method has the necessary
|
66
|
+
# conversation to select the +version+ relevant to +platform+ (or the one nearest
|
67
|
+
# the top of the list if you don't specify +version+).
|
68
|
+
# def select(package, source=nil, version=nil, platform='ruby')
|
69
|
+
def select(package, options={})
|
70
|
+
selections={}
|
71
|
+
cmd="#{GEM_INSTALL} #{options[:version] ? '-v '+options[:version].to_s : nil} " +
|
72
|
+
"#{package} " +
|
73
|
+
"#{options[:source] ? '--source='+options[:source] : nil} " +
|
74
|
+
"#{options[:extra_params] ? options[:extra_params] : nil}"
|
75
|
+
sudo cmd do |channel, stream, data|
|
76
|
+
data.each_line do | line |
|
77
|
+
case line
|
78
|
+
when /\s(\d+).*\(#{options[:platform]}\)/
|
79
|
+
if selections[channel[:host]].nil?
|
80
|
+
selections[channel[:host]]=$1.dup+"\n"
|
81
|
+
logger.info "Selecting #$&", "#{stream} :: #{channel[:host]}"
|
82
|
+
end
|
83
|
+
when /\s\d+\./
|
84
|
+
# Discard other selections from data stream
|
85
|
+
when /^>/
|
86
|
+
channel.send_data selections[channel[:host]]
|
87
|
+
logger.debug line, "#{stream} :: #{channel[:host]}"
|
88
|
+
else
|
89
|
+
logger.info line, "#{stream} :: #{channel[:host]}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
Capistrano.plugin :gem, Gem
|
@@ -0,0 +1,230 @@
|
|
1
|
+
# This library file includes tasks for configuring a Rails application.
|
2
|
+
#
|
3
|
+
# TODO:
|
4
|
+
# * use rails pids dir construct (relinks and change mongrel config)
|
5
|
+
#
|
6
|
+
Capistrano.configuration(:must_exist).load do
|
7
|
+
|
8
|
+
# =============================================================================
|
9
|
+
# DEFAULT VARIABLES
|
10
|
+
# =============================================================================
|
11
|
+
|
12
|
+
set :user, "deploy"
|
13
|
+
set :password, "password"
|
14
|
+
set :group, "users"
|
15
|
+
|
16
|
+
set :deploy_to, "/var/www/apps"
|
17
|
+
|
18
|
+
set :server_name, 'daytona.slingshothosting.com'
|
19
|
+
set :server_ip, '1.2.3.4'
|
20
|
+
set :server_fqdn, 'daytona.slingshothosting.com'
|
21
|
+
|
22
|
+
set :domain_name, 'yourdomain.com'
|
23
|
+
|
24
|
+
# your svn username and password
|
25
|
+
set :svn_username, user
|
26
|
+
set :svn_password, password
|
27
|
+
|
28
|
+
# your database username and password
|
29
|
+
set :database_username, user
|
30
|
+
set :database_password, password
|
31
|
+
|
32
|
+
set :deploy_username, user
|
33
|
+
set :deploy_password, password
|
34
|
+
|
35
|
+
# timezone can be any valid zoneinfo: EST, MST, PST8PDT, GMT
|
36
|
+
set :server_timezone, "GMT"
|
37
|
+
|
38
|
+
# =============================================================================
|
39
|
+
# SOME SEMI-OPTIONAL SLINGSHOT VARIABLES
|
40
|
+
# =============================================================================
|
41
|
+
|
42
|
+
# set this to the correct web start script
|
43
|
+
set :web_server, "apache2"
|
44
|
+
set :path_to_web_server, "/usr/local/apache2/"
|
45
|
+
|
46
|
+
# set this to true to add an apache redirect rule to ensure domain requests to
|
47
|
+
# http://yourdomain.com/ are redirected to http://www.yourdomain.com/
|
48
|
+
set :redirect_www_requests, true
|
49
|
+
|
50
|
+
# ssl certificates must live in the /path/to/apache/conf/ssl directory
|
51
|
+
set :configure_ssl, false # set this to true to use SSL
|
52
|
+
set :ssl_certificate_file, "#{server_name}.pem"
|
53
|
+
set :ssl_certificate_key_file, "#{server_name}.key"
|
54
|
+
set :ssl_ca_certificate_file, 'sf_issuing.crt'
|
55
|
+
|
56
|
+
# set this to the correct db adapter and settings
|
57
|
+
set :database, "mysql"
|
58
|
+
set :database_host, "localhost"
|
59
|
+
|
60
|
+
# saves space by only keeping last 3 when running cleanup
|
61
|
+
set :keep_releases, 3
|
62
|
+
|
63
|
+
# issues svn export instead of checkout
|
64
|
+
set :checkout, "export"
|
65
|
+
|
66
|
+
# mongrel configuration:
|
67
|
+
set :mongrel_conf, "#{current_path}/config/mongrel_cluster.yml"
|
68
|
+
|
69
|
+
# number of mongrel servers to start
|
70
|
+
set :mongrel_servers, 3
|
71
|
+
|
72
|
+
# mongrel starting port
|
73
|
+
set :mongrel_start_port, 8000
|
74
|
+
|
75
|
+
# set this to true to manage your crontab through capistrano
|
76
|
+
set :overwrite_crontab, false
|
77
|
+
set :crontab_email, "root@localhost"
|
78
|
+
|
79
|
+
set :mongrel_cluster_configuration_dir, "/etc/mongrel_cluster"
|
80
|
+
set :rails_apache_configuration_dir, "/etc/rails"
|
81
|
+
|
82
|
+
# =============================================================================
|
83
|
+
# RAILS APPLICATION CONFIGURATION TASKS
|
84
|
+
# =============================================================================
|
85
|
+
|
86
|
+
desc "Tasks to execute before initial setup"
|
87
|
+
task :before_setup do
|
88
|
+
sudo "mkdir -p #{File.dirname(deploy_to)}"
|
89
|
+
sudo "chown -R #{user}:#{group} #{File.dirname(deploy_to)}"
|
90
|
+
|
91
|
+
sudo "mkdir -p #{mongrel_cluster_configuration_dir}"
|
92
|
+
sudo "mkdir -p #{rails_apache_configuration_dir}"
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "Tasks to execute after initial setup"
|
96
|
+
task :after_setup do
|
97
|
+
|
98
|
+
# make shared config dir to hold config files
|
99
|
+
run "mkdir -p #{deploy_to}/#{shared_dir}/config"
|
100
|
+
|
101
|
+
# make a shared tmp dir for sessions
|
102
|
+
run "mkdir -p #{deploy_to}/#{shared_dir}/tmp"
|
103
|
+
run "mkdir -p #{deploy_to}/#{shared_dir}/tmp/cache"
|
104
|
+
run "mkdir -p #{deploy_to}/#{shared_dir}/tmp/sessions"
|
105
|
+
run "mkdir -p #{deploy_to}/#{shared_dir}/tmp/sockets"
|
106
|
+
run "mkdir -p #{deploy_to}/#{shared_dir}/tmp/pids"
|
107
|
+
|
108
|
+
# create any other shared dirs
|
109
|
+
# run "mkdir -p #{deploy_to}/#{shared_dir}/db"
|
110
|
+
# run "mkdir -p #{deploy_to}/#{shared_dir}/db/ferret_index"
|
111
|
+
|
112
|
+
mongrel_configuration_setup
|
113
|
+
database_configuration_setup
|
114
|
+
apache_configuration_setup
|
115
|
+
apache_redirects_setup
|
116
|
+
crontab_configuration_setup
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
desc "Tasks to execute after code update"
|
121
|
+
task :after_update_code, :roles => [:app, :db] do
|
122
|
+
# relink shared deployment database configuration
|
123
|
+
run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
|
124
|
+
|
125
|
+
# relink shared deployment mongrel_cluster configuration
|
126
|
+
run "ln -nfs #{deploy_to}/#{shared_dir}/config/mongrel_cluster.yml #{release_path}/config/mongrel_cluster.yml"
|
127
|
+
|
128
|
+
# relink shared tmp dir (for session and cache data)
|
129
|
+
sudo "rm -rf #{release_path}/tmp" # technically shouldn't be in svn
|
130
|
+
run "ln -nfs #{deploy_to}/#{shared_dir}/tmp #{release_path}/tmp"
|
131
|
+
|
132
|
+
# relink file storage dir
|
133
|
+
sudo "rm -rf #{release_path}/file_storage" # technically shouldn't be in svn
|
134
|
+
run "ln -nfs #{deploy_to}/#{shared_dir}/file_storage #{release_path}/file_storage"
|
135
|
+
|
136
|
+
# rebuild ferret index
|
137
|
+
# run "cd #{release_path} && RAILS_ENV=production rake search:build_index"
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "Setup mongrel Configuration"
|
141
|
+
task :mongrel_configuration_setup do
|
142
|
+
|
143
|
+
# generate a mongrel configuration file
|
144
|
+
mongrel_configuration = render :template => <<-EOF
|
145
|
+
---
|
146
|
+
cwd: #{deploy_to}/current
|
147
|
+
port: "#{mongrel_start_port}"
|
148
|
+
environment: production
|
149
|
+
address: 127.0.0.1
|
150
|
+
pid_file: #{deploy_to}/current/log/mongrel.pid
|
151
|
+
log_file: #{deploy_to}/current/log/mongrel.log
|
152
|
+
servers: #{mongrel_servers}
|
153
|
+
user: #{user}
|
154
|
+
group: #{group}
|
155
|
+
|
156
|
+
EOF
|
157
|
+
|
158
|
+
# put mongrel configuration in shared config dir and link in /etc/mongrel_cluster
|
159
|
+
put mongrel_configuration, "#{deploy_to}/#{shared_dir}/config/mongrel_cluster.yml"
|
160
|
+
sudo "ln -nfs #{deploy_to}/#{shared_dir}/config/mongrel_cluster.yml /etc/mongrel_cluster/#{application}.yml"
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
desc "Setup Database Configuration"
|
165
|
+
task :database_configuration_setup do
|
166
|
+
|
167
|
+
# generate database configuration
|
168
|
+
database_configuration = render :template => <<-EOF
|
169
|
+
# Deployment database.yml
|
170
|
+
login: &login
|
171
|
+
adapter: #{database}
|
172
|
+
username: #{database_username}
|
173
|
+
password: #{database_password}
|
174
|
+
|
175
|
+
development:
|
176
|
+
database: #{application}_development
|
177
|
+
<<: *login
|
178
|
+
|
179
|
+
test:
|
180
|
+
database: #{application}_test
|
181
|
+
<<: *login
|
182
|
+
|
183
|
+
production:
|
184
|
+
database: #{application}_production
|
185
|
+
<<: *login
|
186
|
+
|
187
|
+
EOF
|
188
|
+
|
189
|
+
# put database configuration in shared config dir
|
190
|
+
put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
|
191
|
+
end
|
192
|
+
|
193
|
+
# =============================================================================
|
194
|
+
# SLINGSHOT TASKS
|
195
|
+
# =============================================================================
|
196
|
+
|
197
|
+
desc "Restart the web server"
|
198
|
+
task :restart_web, :roles => [:web] do
|
199
|
+
sudo "/etc/init.d/#{web_server} restart"
|
200
|
+
end
|
201
|
+
|
202
|
+
# =============================================================================
|
203
|
+
# APPLICATION SPECIFIC TASKS
|
204
|
+
# =============================================================================
|
205
|
+
|
206
|
+
desc "Rebuild Ferret search index"
|
207
|
+
task :ferret_index, :roles => [:app, :db] do
|
208
|
+
run("cd #{current_path} && RAILS_ENV=production rake search:build_index")
|
209
|
+
# run("chmod -R ugo+w #{current_path}/db/ferret_index")
|
210
|
+
# run("chmod -R ugo+r #{current_path}/db/ferret_index")
|
211
|
+
end
|
212
|
+
|
213
|
+
# =============================================================================
|
214
|
+
# USEFUL TASKS
|
215
|
+
# =============================================================================
|
216
|
+
|
217
|
+
desc "Disables web site while deploying and in errors - used for long-running deploys"
|
218
|
+
task :long_deploy do
|
219
|
+
transaction do
|
220
|
+
update_code
|
221
|
+
disable_web
|
222
|
+
symlink
|
223
|
+
migrate
|
224
|
+
end
|
225
|
+
|
226
|
+
restart
|
227
|
+
enable_web
|
228
|
+
end
|
229
|
+
|
230
|
+
end # end capistrano extensions
|