dreamcat4-moonshadow 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +165 -0
- data/app_generators/moonshine/moonshine_generator.rb +154 -0
- data/app_generators/moonshine/templates/Capfile +3 -0
- data/app_generators/moonshine/templates/rails/deploy.rb +3 -0
- data/app_generators/moonshine/templates/rails/gems.yml +1 -0
- data/app_generators/moonshine/templates/rails/manifest.rb +55 -0
- data/app_generators/moonshine/templates/rails/moonshine.rake +83 -0
- data/app_generators/moonshine/templates/rails/moonshine.yml +43 -0
- data/app_generators/moonshine/templates/readme.templates +5 -0
- data/app_generators/moonshine_plugin/USAGE +8 -0
- data/app_generators/moonshine_plugin/moonshine_plugin_generator.rb +39 -0
- data/app_generators/moonshine_plugin/templates/README.rdoc +14 -0
- data/app_generators/moonshine_plugin/templates/init.rb +3 -0
- data/app_generators/moonshine_plugin/templates/plugin.rb +19 -0
- data/app_generators/moonshine_plugin/templates/spec.rb +24 -0
- data/app_generators/moonshine_plugin/templates/spec_helper.rb +8 -0
- data/bin/moonshine +17 -0
- data/bin/moonshine_plugin +17 -0
- data/lib/moonshine.rb +7 -0
- data/lib/moonshine/bootstrap/bootstrap.mri.sh +21 -0
- data/lib/moonshine/bootstrap/bootstrap.ree.sh +34 -0
- data/lib/moonshine/capistrano.rb +242 -0
- data/lib/moonshine/manifest.rb +151 -0
- data/lib/moonshine/manifest/rails.rb +54 -0
- data/lib/moonshine/manifest/rails/apache.rb +99 -0
- data/lib/moonshine/manifest/rails/apt_gems.yml +32 -0
- data/lib/moonshine/manifest/rails/mysql.rb +79 -0
- data/lib/moonshine/manifest/rails/os.rb +115 -0
- data/lib/moonshine/manifest/rails/passenger.rb +93 -0
- data/lib/moonshine/manifest/rails/postgresql.rb +83 -0
- data/lib/moonshine/manifest/rails/rails.rb +237 -0
- data/lib/moonshine/manifest/rails/sqlite3.rb +8 -0
- data/lib/moonshine/manifest/rails/templates/innodb.cnf.erb +6 -0
- data/lib/moonshine/manifest/rails/templates/logrotate.conf.erb +15 -0
- data/lib/moonshine/manifest/rails/templates/moonshine.cnf.erb +63 -0
- data/lib/moonshine/manifest/rails/templates/passenger.conf.erb +106 -0
- data/lib/moonshine/manifest/rails/templates/passenger.vhost.erb +273 -0
- data/lib/moonshine/manifest/rails/templates/pg_hba.conf.erb +83 -0
- data/lib/moonshine/manifest/rails/templates/postgresql.conf.erb +493 -0
- data/lib/moonshine/manifest/rails/templates/unattended_upgrades.erb +18 -0
- data/lib/moonshine_setup_manifest.rb +39 -0
- metadata +135 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
:ruby: ree
|
2
|
+
:application: your_app_name
|
3
|
+
:user: rails
|
4
|
+
#:time_zone: UTC
|
5
|
+
:deploy_to: /srv/your_app_name
|
6
|
+
:domain: yourapp.com
|
7
|
+
#:domain_aliases:
|
8
|
+
# - assets1.yourapp.com
|
9
|
+
# - assets2.yourapp.com
|
10
|
+
#:scm: git
|
11
|
+
:repository: git@github.com:username/your_app_name.git
|
12
|
+
# Use :app_symlinks to setup directories under public/ that you want to persist
|
13
|
+
# across deployments. They'll be symlinked to the shared directory.
|
14
|
+
#:app_symlinks:
|
15
|
+
# - uploads
|
16
|
+
#
|
17
|
+
# Use :local_config to copy directories straight from your local project directory
|
18
|
+
# to the server: these are files that you don't have/want in scm.
|
19
|
+
#:local_config:
|
20
|
+
# - config/database.yml
|
21
|
+
#
|
22
|
+
# The entries in shared_children are created in #{application}/shared
|
23
|
+
:shared_children:
|
24
|
+
- system
|
25
|
+
- log
|
26
|
+
- pids
|
27
|
+
- config
|
28
|
+
# After specifying a gem with config.gem, run 'rake moonshine:gems'
|
29
|
+
# to update config/gems.yml. If the gem depends on native packages,
|
30
|
+
# tell Moonshine here:
|
31
|
+
#:apt_gems:
|
32
|
+
# :awesomegem:
|
33
|
+
# - awesome
|
34
|
+
# - libawesome-dev
|
35
|
+
#
|
36
|
+
# See all the options for Passenger, Apache vhosts, and MySQL in the
|
37
|
+
# respective templates: moonshine/lib/moonshine/manifest/rails/templates
|
38
|
+
:passenger:
|
39
|
+
:max_pool_size: 3
|
40
|
+
:use_global_queue: true
|
41
|
+
:mysql:
|
42
|
+
:innodb_buffer_pool_size: 128M
|
43
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class MoonshinePluginGenerator < RubiGen::Base
|
2
|
+
attr_reader :name, :plugin_name, :module_name
|
3
|
+
|
4
|
+
def initialize(runtime_args, runtime_options = {})
|
5
|
+
super
|
6
|
+
usage if args.empty?
|
7
|
+
plugin = args.shift
|
8
|
+
if plugin
|
9
|
+
@name = plugin.downcase.underscore
|
10
|
+
@module_name = @name.camelize
|
11
|
+
@plugin_name = 'moonshine_' + name
|
12
|
+
else
|
13
|
+
puts "Please specify the name of your plugin"
|
14
|
+
puts "moonshine_plugin <name>"
|
15
|
+
puts
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def manifest
|
21
|
+
record do |m|
|
22
|
+
m.directory "vendor/plugins/#{plugin_name}"
|
23
|
+
m.template "README.rdoc", "vendor/plugins/#{plugin_name}/README.rdoc"
|
24
|
+
m.directory "vendor/plugins/#{plugin_name}/moonshine"
|
25
|
+
m.template 'init.rb', "vendor/plugins/#{plugin_name}/moonshine/init.rb"
|
26
|
+
m.directory "vendor/plugins/#{plugin_name}/lib"
|
27
|
+
m.template 'plugin.rb', "vendor/plugins/#{plugin_name}/lib/#{name}.rb"
|
28
|
+
m.directory "vendor/plugins/#{plugin_name}/spec"
|
29
|
+
m.template 'spec.rb', "vendor/plugins/#{plugin_name}/spec/#{name}_spec.rb"
|
30
|
+
m.template 'spec_helper.rb', "vendor/plugins/#{plugin_name}/spec/spec_helper.rb"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Override with your own usage banner.
|
35
|
+
def banner
|
36
|
+
"Usage: #{$0} <plugin name> [options]"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
= Moonshine_<%= module_name %>
|
2
|
+
|
3
|
+
=== A plugin for Moonshine[http://github.com/railsmachine/moonshine]
|
4
|
+
|
5
|
+
A plugin for installing and managing <%= name %>.
|
6
|
+
|
7
|
+
=== Instructions
|
8
|
+
|
9
|
+
* <tt>script/plugin install git://github.com/ACCOUNT/<%= plugin_name%>.git</tt>
|
10
|
+
* Configure settings if needed
|
11
|
+
configure(:<%= name %> => {:foo => true})
|
12
|
+
* Include the plugin and recipe(s) in your Moonshine manifest
|
13
|
+
plugin :<%= name %>
|
14
|
+
recipe :<%= name %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module <%= module_name %>
|
2
|
+
|
3
|
+
# Define options for this plugin via the <tt>configure</tt> method
|
4
|
+
# in your application manifest:
|
5
|
+
#
|
6
|
+
# configure(:<%= name %> => {:foo => true})
|
7
|
+
#
|
8
|
+
# Then include the plugin and call the recipe(s) you need:
|
9
|
+
#
|
10
|
+
# plugin :<%= name %>
|
11
|
+
# recipe :<%= name %>
|
12
|
+
def <%= name %>(options = {})
|
13
|
+
# define the recipe
|
14
|
+
# options specified with the configure method will be
|
15
|
+
# automatically available here in the options hash.
|
16
|
+
# options[:foo] # => true
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper.rb')
|
2
|
+
|
3
|
+
class <%= module_name %>Manifest < Moonshine::Manifest
|
4
|
+
plugin :<%= name %>
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "A manifest with the <%= module_name %> plugin" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@manifest = <%= module_name %>Manifest.new
|
11
|
+
@manifest.<%= name %>
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be executable" do
|
15
|
+
@manifest.should be_executable
|
16
|
+
end
|
17
|
+
|
18
|
+
#it "should provide packages/services/files" do
|
19
|
+
# @manifest.packages.keys.should include 'foo'
|
20
|
+
# @manifest.files['/etc/foo.conf'].content.should match /foo=true/
|
21
|
+
# @manifest.execs['newaliases'].refreshonly.should be_true
|
22
|
+
#end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
|
+
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'moonshine', 'lib', 'moonshine.rb')
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', '<%= name %>.rb')
|
7
|
+
|
8
|
+
require 'shadow_puppet/test'
|
data/bin/moonshine
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
# if %w(-v --version).include? ARGV.first
|
7
|
+
# require 'moonshine/version'
|
8
|
+
# puts "#{File.basename($0)} #{Moonshine::VERSION}"
|
9
|
+
# exit(0)
|
10
|
+
# end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
source = RubiGen::PathSource.new(:application,
|
14
|
+
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
|
+
RubiGen::Base.reset_sources
|
16
|
+
RubiGen::Base.append_sources source
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'moonshine')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
# if %w(-v --version).include? ARGV.first
|
7
|
+
# require 'moonshine/version'
|
8
|
+
# puts "#{File.basename($0)} #{Moonshine::VERSION}"
|
9
|
+
# exit(0)
|
10
|
+
# end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
source = RubiGen::PathSource.new(:application,
|
14
|
+
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
|
+
RubiGen::Base.reset_sources
|
16
|
+
RubiGen::Base.append_sources source
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'moonshine_plugin')
|
data/lib/moonshine.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
apt-get update
|
4
|
+
|
5
|
+
echo "Installing build packages"
|
6
|
+
apt-get install -q -y build-essential zlib1g-dev libssl-dev libreadline5-dev wget
|
7
|
+
|
8
|
+
echo "Installing Ruby"
|
9
|
+
apt-get install -q -y ruby-full
|
10
|
+
|
11
|
+
echo "Installing RubyGems"
|
12
|
+
cd /tmp
|
13
|
+
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
|
14
|
+
tar xfz rubygems-1.3.1.tgz
|
15
|
+
cd rubygems-1.3.1
|
16
|
+
ruby setup.rb
|
17
|
+
ln -s /usr/bin/gem1.8 /usr/bin/gem
|
18
|
+
gem update --system
|
19
|
+
cd ..
|
20
|
+
echo "Cleaning up RubyGems Download"
|
21
|
+
rm -rf rubygems-1.3.1*
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
apt-get update
|
4
|
+
|
5
|
+
echo "Installing build packages"
|
6
|
+
apt-get install -q -y build-essential zlib1g-dev libssl-dev libreadline5-dev wget
|
7
|
+
|
8
|
+
echo "Removing Ruby from apt"
|
9
|
+
apt-get remove -q -y ^ruby*
|
10
|
+
|
11
|
+
PREFIX="/usr"
|
12
|
+
REE="ruby-enterprise-1.8.6-20090610"
|
13
|
+
|
14
|
+
if [ -z `which ruby` ] || [ "$FORCE_RUBY" = "true" ]; then
|
15
|
+
|
16
|
+
echo "Installing Ruby"
|
17
|
+
|
18
|
+
cd /tmp
|
19
|
+
echo "Downloading REE"
|
20
|
+
wget -q http://assets.railsmachine.com/other/$REE.tar.gz
|
21
|
+
echo "Untar REE"
|
22
|
+
tar xzf $REE.tar.gz
|
23
|
+
|
24
|
+
echo "Running installer"
|
25
|
+
./$REE/installer --dont-install-useful-gems -a $PREFIX
|
26
|
+
|
27
|
+
echo "Cleaning up REE download"
|
28
|
+
rm -rf $REE*
|
29
|
+
|
30
|
+
else
|
31
|
+
|
32
|
+
echo "Ruby already installed."
|
33
|
+
|
34
|
+
fi
|
@@ -0,0 +1,242 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
set :branch, 'master'
|
4
|
+
set :scm, :git
|
5
|
+
set :git_enable_submodules, 1
|
6
|
+
ssh_options[:paranoid] = false
|
7
|
+
ssh_options[:forward_agent] = true
|
8
|
+
default_run_options[:pty] = true
|
9
|
+
set :keep_releases, 2
|
10
|
+
|
11
|
+
after 'deploy:restart', 'deploy:cleanup'
|
12
|
+
|
13
|
+
#load the moonshine configuration into
|
14
|
+
require 'yaml'
|
15
|
+
hash = YAML.load_file(File.join((ENV['RAILS_ROOT'] || Dir.pwd), 'config', 'moonshine.yml'))
|
16
|
+
hash.each do |key, value|
|
17
|
+
set(key.to_sym, value)
|
18
|
+
end
|
19
|
+
|
20
|
+
set :scm, :svn if !! repository =~ /^svn/
|
21
|
+
|
22
|
+
namespace :moonshine do
|
23
|
+
|
24
|
+
desc <<-DESC
|
25
|
+
Bootstrap a barebones Ubuntu system with Git, Ruby, RubyGems, and Moonshine
|
26
|
+
dependencies. Called by deploy:setup.
|
27
|
+
DESC
|
28
|
+
task :bootstrap do
|
29
|
+
ruby.install
|
30
|
+
ensure_installed
|
31
|
+
setup_directories
|
32
|
+
end
|
33
|
+
|
34
|
+
task :setup_directories do
|
35
|
+
begin
|
36
|
+
config = YAML.load_file(File.join(Dir.pwd, 'config', 'moonshine.yml'))
|
37
|
+
put(YAML.dump(config),"/tmp/moonshine.yml")
|
38
|
+
rescue Exception => e
|
39
|
+
puts e
|
40
|
+
puts "Please make sure the settings in moonshine.yml are valid and that the target hostname is correct."
|
41
|
+
exit(0)
|
42
|
+
end
|
43
|
+
put(File.read(File.join(File.dirname(__FILE__), '..', 'moonshine_setup_manifest.rb')),"/tmp/moonshine_setup_manifest.rb")
|
44
|
+
sudo "shadow_puppet /tmp/moonshine_setup_manifest.rb"
|
45
|
+
sudo 'rm /tmp/moonshine_setup_manifest.rb'
|
46
|
+
sudo 'rm /tmp/moonshine.yml'
|
47
|
+
end
|
48
|
+
|
49
|
+
task :ensure_installed do
|
50
|
+
begin
|
51
|
+
run "ruby -e 'require \"rubygems\"; gem \"moonshine\", \"= #{Gem.loaded_specs["moonshine"].version}\"' 2> /dev/null"
|
52
|
+
rescue
|
53
|
+
sudo "gem install moonshine -v #{Gem.loaded_specs["moonshine"].version}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
desc 'Apply the Moonshine manifest for this application'
|
58
|
+
task :apply do
|
59
|
+
on_rollback do
|
60
|
+
run "cd #{latest_release} && RAILS_ENV=#{fetch(:rails_env, 'production')} rake --trace environment"
|
61
|
+
end
|
62
|
+
ensure_installed
|
63
|
+
sudo "RAILS_ROOT=#{latest_release} DEPLOY_STAGE=#{ENV['DEPLOY_STAGE']||fetch(:stage,'undefined')} RAILS_ENV=#{fetch(:rails_env, 'production')} shadow_puppet #{latest_release}/app/manifests/#{fetch(:moonshine_manifest, 'application_manifest')}.rb"
|
64
|
+
sudo "touch /var/log/moonshine_rake.log && cat /var/log/moonshine_rake.log"
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Update code and then run a console. Useful for debugging deployment."
|
68
|
+
task :update_and_console do
|
69
|
+
set :moonshine_apply, false
|
70
|
+
deploy.update_code
|
71
|
+
app.console
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Update code and then run 'rake environment'. Useful for debugging deployment."
|
75
|
+
task :update_and_rake do
|
76
|
+
set :moonshine_apply, false
|
77
|
+
deploy.update_code
|
78
|
+
run "cd #{latest_release} && RAILS_ENV=#{fetch(:rails_env, 'production')} rake --trace environment"
|
79
|
+
end
|
80
|
+
|
81
|
+
after 'deploy:finalize_update' do
|
82
|
+
local_config.upload
|
83
|
+
local_config.symlink
|
84
|
+
app.symlinks.update
|
85
|
+
end
|
86
|
+
|
87
|
+
before 'deploy:symlink' do
|
88
|
+
apply if fetch(:moonshine_apply, true) == true
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
namespace :app do
|
94
|
+
|
95
|
+
namespace :symlinks do
|
96
|
+
|
97
|
+
desc <<-DESC
|
98
|
+
Link public directories to shared location.
|
99
|
+
DESC
|
100
|
+
task :update, :roles => [:app, :web] do
|
101
|
+
fetch(:app_symlinks, []).each { |link| run "ln -nfs #{shared_path}/public/#{link} #{latest_release}/public/#{link}" }
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
desc "remotely console"
|
107
|
+
task :console, :roles => :app, :except => {:no_symlink => true} do
|
108
|
+
input = ''
|
109
|
+
run "cd #{current_path} && ./script/console #{fetch(:rails_env, "production")}" do |channel, stream, data|
|
110
|
+
next if data.chomp == input.chomp || data.chomp == ''
|
111
|
+
print data
|
112
|
+
channel.send_data(input = $stdin.gets) if data =~ /^(>|\?)>/
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
desc "Show requests per second"
|
117
|
+
task :rps, :roles => :app, :except => {:no_symlink => true} do
|
118
|
+
count = 0
|
119
|
+
last = Time.now
|
120
|
+
run "tail -f #{shared_path}/log/#{fetch(:rails_env, "production")}.log" do |ch, stream, out|
|
121
|
+
break if stream == :err
|
122
|
+
count += 1 if out =~ /^Completed in/
|
123
|
+
if Time.now - last >= 1
|
124
|
+
puts "#{ch[:host]}: %2d Requests / Second" % count
|
125
|
+
count = 0
|
126
|
+
last = Time.now
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
desc "tail application log file"
|
132
|
+
task :log, :roles => :app, :except => {:no_symlink => true} do
|
133
|
+
run "tail -f #{shared_path}/log/#{fetch(:rails_env, "production")}.log" do |channel, stream, data|
|
134
|
+
puts "#{data}"
|
135
|
+
break if stream == :err
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
desc "tail vmstat"
|
140
|
+
task :vmstat, :roles => [:web, :db] do
|
141
|
+
run "vmstat 5" do |channel, stream, data|
|
142
|
+
puts "[#{channel[:host]}]"
|
143
|
+
puts data.gsub(/\s+/, "\t")
|
144
|
+
break if stream == :err
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
namespace :local_config do
|
151
|
+
|
152
|
+
desc <<-DESC
|
153
|
+
Uploads local configuration files to the application's shared directory for
|
154
|
+
later symlinking (if necessary). Called if local_config is set.
|
155
|
+
DESC
|
156
|
+
task :upload do
|
157
|
+
fetch(:local_config,[]).each do |file|
|
158
|
+
filename = File.split(file).last
|
159
|
+
if File.exist?( file )
|
160
|
+
put(File.read( file ),"#{shared_path}/config/#{filename}")
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
desc <<-DESC
|
166
|
+
Symlinks uploaded local configurations into the release directory.
|
167
|
+
DESC
|
168
|
+
task :symlink do
|
169
|
+
fetch(:local_config,[]).each do |file|
|
170
|
+
filename = File.split(file).last
|
171
|
+
run "ls #{latest_release}/#{file} 2> /dev/null || ln -nfs #{shared_path}/config/#{filename} #{latest_release}/#{file}"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
namespace :deploy do
|
178
|
+
desc "Restart the Passenger processes on the app server by touching tmp/restart.txt."
|
179
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
180
|
+
run "touch #{current_path}/tmp/restart.txt"
|
181
|
+
end
|
182
|
+
|
183
|
+
[:start, :stop].each do |t|
|
184
|
+
desc "#{t} task is a no-op with Passenger"
|
185
|
+
task t, :roles => :app do ; end
|
186
|
+
end
|
187
|
+
|
188
|
+
desc <<-DESC
|
189
|
+
Prepares one or more servers for deployment. Before you can use any \
|
190
|
+
of the Capistrano deployment tasks with your project, you will need to \
|
191
|
+
make sure all of your servers have been prepared with `cap deploy:setup'. When \
|
192
|
+
you add a new server to your cluster, you can easily run the setup task \
|
193
|
+
on just that server by specifying the HOSTS environment variable:
|
194
|
+
|
195
|
+
$ cap HOSTS=new.server.com deploy:setup
|
196
|
+
|
197
|
+
It is safe to run this task on servers that have already been set up; it \
|
198
|
+
will not destroy any deployed revisions or data.
|
199
|
+
DESC
|
200
|
+
task :setup, :except => { :no_release => true } do
|
201
|
+
moonshine.bootstrap
|
202
|
+
vcs.install
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
namespace :ruby do
|
207
|
+
desc "Forces a reinstall of Ruby and restarts Apache/Passenger"
|
208
|
+
task :upgrade do
|
209
|
+
set :force_ruby, 'true'
|
210
|
+
install
|
211
|
+
apache.restart
|
212
|
+
end
|
213
|
+
|
214
|
+
desc "Install Ruby + Rubygems"
|
215
|
+
task :install do
|
216
|
+
put(File.read(File.join(File.dirname(__FILE__), 'bootstrap', "bootstrap.#{fetch(:ruby, 'ree')}.sh")),"/tmp/bootstrap.sh")
|
217
|
+
sudo 'chmod a+x /tmp/bootstrap.sh'
|
218
|
+
sudo "FORCE_RUBY=#{fetch(:force_ruby,'false')} /tmp/bootstrap.sh"
|
219
|
+
sudo 'rm /tmp/bootstrap.sh'
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
namespace :apache do
|
224
|
+
desc "Restarts the Apache web server"
|
225
|
+
task :restart do
|
226
|
+
sudo 'service apache2 restart'
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
namespace :vcs do
|
231
|
+
desc "Installs the scm"
|
232
|
+
task :install do
|
233
|
+
package = case fetch(:scm).to_s
|
234
|
+
when 'svn' then 'subversion'
|
235
|
+
when 'git' then 'git-core'
|
236
|
+
else scm.to_s
|
237
|
+
end
|
238
|
+
sudo "apt-get -qq -y install #{package}"
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|