teknobingo-recipes 0.1.39
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.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/LICENSE +1 -0
- data/README.rdoc +18 -0
- data/Rakefile +2 -0
- data/lib/teknobingo_recipes.rb +1 -0
- data/lib/teknobingo_recipes/helpers.rb +67 -0
- data/lib/teknobingo_recipes/recipes/apache.rb +62 -0
- data/lib/teknobingo_recipes/recipes/base.rb +16 -0
- data/lib/teknobingo_recipes/recipes/check.rb +13 -0
- data/lib/teknobingo_recipes/recipes/logrotate.rb +9 -0
- data/lib/teknobingo_recipes/recipes/memcached.rb +24 -0
- data/lib/teknobingo_recipes/recipes/mogilefs.rb +146 -0
- data/lib/teknobingo_recipes/recipes/nfs.rb +99 -0
- data/lib/teknobingo_recipes/recipes/nginx.rb +75 -0
- data/lib/teknobingo_recipes/recipes/nodejs.rb +15 -0
- data/lib/teknobingo_recipes/recipes/passenger.rb +68 -0
- data/lib/teknobingo_recipes/recipes/postgresql.rb +44 -0
- data/lib/teknobingo_recipes/recipes/profile.rb +43 -0
- data/lib/teknobingo_recipes/recipes/rainbows.rb +83 -0
- data/lib/teknobingo_recipes/recipes/rbenv.rb +40 -0
- data/lib/teknobingo_recipes/recipes/redis.rb +31 -0
- data/lib/teknobingo_recipes/version.rb +3 -0
- data/teknobingo-recipes.gemspec +27 -0
- data/templates/bash/lesslog.sh +1 -0
- data/templates/bash/profile +1 -0
- data/templates/bash/prompt.sh +13 -0
- data/templates/bash/railsc.sh +1 -0
- data/templates/bash/taillog.sh +1 -0
- data/templates/init.d/nginx +362 -0
- data/templates/logrotate.erb +14 -0
- data/templates/memcached.erb +16 -0
- data/templates/mogilefsd_conf.erb +7 -0
- data/templates/mogstored_conf.erb +3 -0
- data/templates/nginx.conf.erb +23 -0
- data/templates/passenger_mod.erb +3 -0
- data/templates/postgresql.yml.erb +8 -0
- data/templates/redis_conf.erb +419 -0
- data/templates/vhosts/http_site.erb +7 -0
- metadata +98 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
set_default :web_server, :nginx
|
|
2
|
+
set_default :rack_server, :passenger
|
|
3
|
+
|
|
4
|
+
namespace :nginx do
|
|
5
|
+
|
|
6
|
+
def passenger_root_and_ruby
|
|
7
|
+
@passenger_root_and_ruby ||= begin
|
|
8
|
+
passenger_ruby = nil
|
|
9
|
+
passenger_root = nil
|
|
10
|
+
run "cat /opt/nginx/conf/nginx.conf",:pty => true do |ch, stream, data|
|
|
11
|
+
if /passenger_root (?<root>.*);$/ =~ data
|
|
12
|
+
passenger_root = root
|
|
13
|
+
elsif /passenger_ruby (?<ruby>.*);$/ =~ data
|
|
14
|
+
passenger_ruby = ruby
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
[passenger_root,passenger_ruby]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def passenger_root
|
|
22
|
+
passenger_root_and_ruby[0]
|
|
23
|
+
end
|
|
24
|
+
def passenger_ruby
|
|
25
|
+
passenger_root_and_ruby[1]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
desc "Setup NGINX"
|
|
29
|
+
task :install, roles: :web do
|
|
30
|
+
run "#{sudo} apt-get -y install nginx"
|
|
31
|
+
end
|
|
32
|
+
after "deploy:setup", "nginx:install" if web_server == :nginx && rack_server != :passenger
|
|
33
|
+
|
|
34
|
+
desc "Setup NGINX"
|
|
35
|
+
task :setup, roles: :web do
|
|
36
|
+
|
|
37
|
+
if rack_server == :passenger
|
|
38
|
+
set :passenger_root, passenger_root
|
|
39
|
+
set :passenger_ruby, passenger_ruby
|
|
40
|
+
|
|
41
|
+
template "init.d/nginx", "/tmp/nginx"
|
|
42
|
+
run "#{sudo} mv /tmp/nginx /etc/init.d/nginx"
|
|
43
|
+
run "#{sudo} chown root:root /etc/init.d/nginx"
|
|
44
|
+
run "#{sudo} chmod +x /etc/init.d/nginx"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
run "#{sudo} /usr/sbin/update-rc.d -f nginx defaults"
|
|
48
|
+
end
|
|
49
|
+
after "deploy:setup", "nginx:setup" if web_server == :nginx
|
|
50
|
+
|
|
51
|
+
desc "Setup Site for nginx"
|
|
52
|
+
task :setup_site, roles: :web do
|
|
53
|
+
root = (rack_server == :passenger) ? '/opt/nginx' : '/etc/nginx'
|
|
54
|
+
|
|
55
|
+
if rack_server == :passenger
|
|
56
|
+
template "nginx.conf.erb", "/tmp/nginx.conf"
|
|
57
|
+
run "#{sudo} mv /tmp/nginx.conf #{root}/conf/nginx.conf"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
template "vhosts/http_site.erb", "/tmp/http_site"
|
|
61
|
+
run "#{sudo} mkdir -p #{root}/sites-available"
|
|
62
|
+
run "#{sudo} mkdir -p #{root}/sites-enabled"
|
|
63
|
+
run "#{sudo} mv /tmp/http_site #{root}/sites-available/#{application}.site"
|
|
64
|
+
run "#{sudo} ln -s #{root}/sites-available/#{application}.site #{root}/sites-enabled"
|
|
65
|
+
end
|
|
66
|
+
after "nginx:setup", "nginx:setup_site"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
%w[start stop reload restart status].each do |command|
|
|
70
|
+
desc "#{command} NGINX"
|
|
71
|
+
task command, roles: :web do
|
|
72
|
+
run "#{sudo} /etc/init.d/nginx #{command}"
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
namespace :nodejs do
|
|
2
|
+
desc "Install the latest relase of Node.js"
|
|
3
|
+
task :install, roles: :web do
|
|
4
|
+
run "#{sudo} add-apt-repository ppa:chris-lea/node.js",:pty => true do |ch, stream, data|
|
|
5
|
+
if data =~ /Press.\[ENTER\].to.continue/
|
|
6
|
+
ch.send_data("\n")
|
|
7
|
+
else
|
|
8
|
+
Capistrano::Configuration.default_io_proc.call(ch,stream,data)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
run "#{sudo} apt-get -y update"
|
|
12
|
+
run "#{sudo} apt-get -y install nodejs"
|
|
13
|
+
end
|
|
14
|
+
after "deploy:install", "nodejs:install"
|
|
15
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
set_default :rack_server, :passenger
|
|
2
|
+
|
|
3
|
+
namespace :passenger do
|
|
4
|
+
def passenger_root_and_ruby
|
|
5
|
+
@passenger_root_and_ruby ||= begin
|
|
6
|
+
passenger_ruby = nil
|
|
7
|
+
passenger_root = nil
|
|
8
|
+
run "cat /opt/nginx/conf/nginx.conf",:pty => true do |ch, stream, data|
|
|
9
|
+
if /passenger_root (?<root>.*);$/ =~ data
|
|
10
|
+
passenger_root = root
|
|
11
|
+
elsif /passenger_ruby (?<ruby>.*);$/ =~ data
|
|
12
|
+
passenger_ruby = ruby
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
[passenger_root,passenger_ruby]
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def passenger_root
|
|
20
|
+
#passenger_root_and_ruby[0]
|
|
21
|
+
@passenger_root ||= capture("passenger-config --root").strip
|
|
22
|
+
end
|
|
23
|
+
def passenger_ruby
|
|
24
|
+
passenger_root_and_ruby[1]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
desc "Install passenger"
|
|
28
|
+
task :install, roles: :web do
|
|
29
|
+
|
|
30
|
+
unless [:apache, :nginx].include?(web_server)
|
|
31
|
+
puts "WARNING: No WEB SERVER specified, good luck!".red
|
|
32
|
+
else
|
|
33
|
+
run "#{sudo} apt-get -y install libcurl3-openssl-dev"
|
|
34
|
+
if web_server == :nginx
|
|
35
|
+
run "gem install specific_install"
|
|
36
|
+
run "gem specific_install -l https://github.com/phusion/passenger.git"
|
|
37
|
+
#run "gem install passenger --no-ri --no-rdoc"
|
|
38
|
+
|
|
39
|
+
run "#{sudo} /home/capistrano/.rbenv/shims/passenger-install-nginx-module --auto",:pty => true do |ch, stream, data|
|
|
40
|
+
if data.strip == 'Enter your choice (1 or 2) or press Ctrl-C to abort:'
|
|
41
|
+
ch.send_data("1\n")
|
|
42
|
+
elsif data =~ /Please specify a prefix directory/
|
|
43
|
+
ch.send_data("\n")
|
|
44
|
+
else
|
|
45
|
+
Capistrano::Configuration.default_io_proc.call(ch,stream,data)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
set :passenger_root, passenger_root
|
|
50
|
+
set :passenger_ruby, passenger_ruby
|
|
51
|
+
elsif web_server == :apache
|
|
52
|
+
run "gem install passenger --no-ri --no-rdoc"
|
|
53
|
+
run "passenger-install-apache2-module --auto",:pty => true do |ch, stream, data|
|
|
54
|
+
if data =~ /Press Enter to continue, or Ctrl-C to abort/
|
|
55
|
+
ch.send_data("\n")
|
|
56
|
+
elsif data =~ /Press ENTER to continue/
|
|
57
|
+
ch.send_data("\n")
|
|
58
|
+
else
|
|
59
|
+
Capistrano::Configuration.default_io_proc.call(ch,stream,data)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
run "rbenv rehash"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
after "deploy:install", "passenger:install"
|
|
67
|
+
end
|
|
68
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
set_default(:postgresql_host, "localhost")
|
|
2
|
+
set_default(:postgresql_user) { application }
|
|
3
|
+
set_default(:postgresql_password) { Capistrano::CLI.password_prompt "PostgreSQL Password: " }
|
|
4
|
+
set_default(:postgresql_database) { "#{application}_#{rails_env}" }
|
|
5
|
+
|
|
6
|
+
namespace :postgresql do
|
|
7
|
+
desc "Install the latest stable release of PostgreSQL."
|
|
8
|
+
task :install, roles: :db, only: {primary: true} do
|
|
9
|
+
# The functionality of this has been moved to apt.postgresql.org, see https://wiki.postgresql.org/wiki/Apt for details
|
|
10
|
+
#run "#{sudo} add-apt-repository -y ppa:pitti/postgresql"
|
|
11
|
+
#run "#{sudo} apt-get -y update"
|
|
12
|
+
run "#{sudo} apt-get -y install postgresql libpq-dev"
|
|
13
|
+
end
|
|
14
|
+
#after "deploy:install", "postgresql:install"
|
|
15
|
+
|
|
16
|
+
desc "Install the latest stable release of PostgreSQL-client."
|
|
17
|
+
task :install_client, roles: [:app, :web] do
|
|
18
|
+
#run "#{sudo} add-apt-repository ppa:pitti/postgresql"
|
|
19
|
+
#run "#{sudo} apt-get -y update"
|
|
20
|
+
run "#{sudo} apt-get -y install postgresql-client libpq-dev"
|
|
21
|
+
end
|
|
22
|
+
after "deploy:install", "postgresql:install_client"
|
|
23
|
+
|
|
24
|
+
desc "Create a database for this application."
|
|
25
|
+
task :create_database, roles: :db, only: {primary: true} do
|
|
26
|
+
run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
|
|
27
|
+
run %Q{#{sudo} -u postgres psql -c "alter role #{postgresql_user} createdb login;"}
|
|
28
|
+
run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
|
|
29
|
+
end
|
|
30
|
+
# after "deploy:setup", "postgresql:create_database"
|
|
31
|
+
|
|
32
|
+
desc "Generate the database.yml configuration file."
|
|
33
|
+
task :setup, roles: [:app, :web] do
|
|
34
|
+
run "mkdir -p #{shared_path}/config"
|
|
35
|
+
template "postgresql.yml.erb", "#{shared_path}/config/database.yml"
|
|
36
|
+
end
|
|
37
|
+
# after "deploy:setup", "postgresql:setup"
|
|
38
|
+
|
|
39
|
+
desc "Symlink the database.yml file into latest release"
|
|
40
|
+
task :symlink, roles: [:app, :web] do
|
|
41
|
+
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
|
42
|
+
end
|
|
43
|
+
# after "deploy:finalize_update", "postgresql:symlink"
|
|
44
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
namespace :profile do
|
|
2
|
+
namespace :setup do
|
|
3
|
+
desc "Environment setup."
|
|
4
|
+
task :default, roles: [:app, :web] do
|
|
5
|
+
run "mkdir -p .bash"
|
|
6
|
+
Dir.foreach(File.expand_path('../../../../templates/bash', __FILE__)) do |file|
|
|
7
|
+
unless file[0] == '.'
|
|
8
|
+
template "bash/#{file}", ".bash/#{file}"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
enrich_file '.gemrc', 'gem: --no-rdoc --no-ri', 'no-rdoc'
|
|
12
|
+
enrich_file '.profile', "export RAILS_ENV=#{rails_env}"
|
|
13
|
+
enrich_file '.profile', 'source ~/.bash/profile'
|
|
14
|
+
end
|
|
15
|
+
after "deploy:setup", "profile:setup"
|
|
16
|
+
|
|
17
|
+
desc "Setup trusted ssh keys"
|
|
18
|
+
task :trusted_keys, roles: [:app, :web] do
|
|
19
|
+
begin
|
|
20
|
+
File.open("#{ENV['HOME']}/.ssh/id_rsa.pub") do |file|
|
|
21
|
+
@key = file.gets.chomp
|
|
22
|
+
@signature = @key.sub(/^(.+)?\s(.+)$/,'\2')
|
|
23
|
+
end
|
|
24
|
+
rescue
|
|
25
|
+
end
|
|
26
|
+
if @signature
|
|
27
|
+
filename = '.ssh/authorized_keys'
|
|
28
|
+
run "[ -f #{filename} ] && echo ok || echo not_found" do |channel, stream, data|
|
|
29
|
+
case data.chop.to_sym
|
|
30
|
+
when :ok
|
|
31
|
+
when :not_found
|
|
32
|
+
run "mkdir -p ~/.ssh -m 700 && touch #{filename} && chmod 600 #{filename}"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
enrich_file filename, @key, @signature
|
|
36
|
+
else
|
|
37
|
+
puts "No public key found."
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
after "deploy:install", "profile:setup:trusted_keys"
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
set_default :rack_server, :rainbows
|
|
2
|
+
|
|
3
|
+
set_default(:rainbows_pid){ "#{current_path}/tmp/pids/rainbows.pid" }
|
|
4
|
+
set_default(:rainbows_bin){ "BUNDLE_GEMFILE=#{current_path}/Gemfile bundle exec rainbows" }
|
|
5
|
+
set_default(:rainbows_config){ "#{current_path}/config/rainbows.rb" }
|
|
6
|
+
|
|
7
|
+
# Check if remote file exists
|
|
8
|
+
def remote_file_exists?(full_path)
|
|
9
|
+
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Check if process is running
|
|
13
|
+
def remote_process_exists?(pid_file)
|
|
14
|
+
capture("ps -p $(cat #{pid_file}) ; true").strip.split("\n").size == 2
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
namespace :rainbows do
|
|
18
|
+
desc "Start rainbows server"
|
|
19
|
+
task :start, roles: :web, except: {no_release: true} do
|
|
20
|
+
if remote_file_exists?(rainbows_pid)
|
|
21
|
+
if remote_process_exists?(rainbows_pid)
|
|
22
|
+
logger.important("Rainbows! is already running!", "rainbows")
|
|
23
|
+
next
|
|
24
|
+
else
|
|
25
|
+
run "rm #{rainbows_pid}"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if remote_file_exists?(rainbows_config)
|
|
30
|
+
logger.important("Starting...", "rainbows")
|
|
31
|
+
run "cd #{current_path}; #{rainbows_bin} -c #{rainbows_config} -E #{rails_env} -D"
|
|
32
|
+
else
|
|
33
|
+
logger.important("Config file was not found at \"#{rainbows_config}\"", "rainbows")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
desc "Kill rainbows server"
|
|
38
|
+
task :terminate, roles: :web, except: {no_release: true} do
|
|
39
|
+
if remote_file_exists?(rainbows_pid)
|
|
40
|
+
if remote_process_exists?(rainbows_pid)
|
|
41
|
+
logger.important("Terminating...", "rainbows")
|
|
42
|
+
run "#{try_sudo} kill -s TERM `cat #{rainbows_pid}`"
|
|
43
|
+
else
|
|
44
|
+
run "rm #{rainbows_pid}"
|
|
45
|
+
logger.important("Rainbows! is not running.", "rainbows")
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
logger.important("No PIDs found. Check if rainbows is running.", "rainbows")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
desc "Restart rails application"
|
|
53
|
+
task :restart, roles: :web, except: {no_release: true} do
|
|
54
|
+
if remote_file_exists?(rainbows_pid)
|
|
55
|
+
if remote_process_exists?(rainbows_pid)
|
|
56
|
+
logger.important("Restarting...", "rainbows")
|
|
57
|
+
run "#{try_sudo} kill -s USR2 `cat #{rainbows_pid}`"
|
|
58
|
+
else
|
|
59
|
+
run "rm #{rainbows_pid}"
|
|
60
|
+
logger.important("Rainbows! is not running.", "rainbows")
|
|
61
|
+
start
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
logger.important("No PIDs found.", "rainbows")
|
|
65
|
+
start
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
desc "Gracefully stop rainbows server"
|
|
70
|
+
task :stop, roles: :web, except: {no_release: true} do
|
|
71
|
+
if remote_file_exists?(rainbows_pid)
|
|
72
|
+
if remote_process_exists?(rainbows_pid)
|
|
73
|
+
logger.important("Stopping...", "rainbows")
|
|
74
|
+
run "#{try_sudo} kill -s QUIT `cat #{rainbows_pid}`"
|
|
75
|
+
else
|
|
76
|
+
run "rm #{rainbows_pid}"
|
|
77
|
+
logger.important("Rainbows! is not running.", "rainbows")
|
|
78
|
+
end
|
|
79
|
+
else
|
|
80
|
+
logger.important("No PIDs found. Check if rainbows is running.", "rainbows")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
set_default :ruby_version, "2.0.0-p0"
|
|
2
|
+
set_default :rbenv_bootstrap, "bootstrap-ubuntu-12-04"
|
|
3
|
+
|
|
4
|
+
namespace :rbenv do
|
|
5
|
+
|
|
6
|
+
namespace :install do
|
|
7
|
+
desc "Install rbenv, Ruby, and the Bundler gem"
|
|
8
|
+
task :default, roles: [:app, :web] do
|
|
9
|
+
run "#{sudo} apt-get -y install curl git-core"
|
|
10
|
+
run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
|
|
11
|
+
bashrc = <<-BASHRC
|
|
12
|
+
if [ -d $HOME/.rbenv ]; then
|
|
13
|
+
export PATH="$HOME/.rbenv/bin:$PATH"
|
|
14
|
+
eval "$(rbenv init -)"
|
|
15
|
+
fi
|
|
16
|
+
BASHRC
|
|
17
|
+
put bashrc, "/tmp/rbenvrc"
|
|
18
|
+
run "cat /tmp/rbenvrc ~/.bashrc > ~/.bashrc.tmp"
|
|
19
|
+
run "mv ~/.bashrc.tmp ~/.bashrc"
|
|
20
|
+
run %q{export PATH="$HOME/.rbenv/bin:$PATH"}
|
|
21
|
+
run %q{eval "$(rbenv init -)"}
|
|
22
|
+
run "#{sudo} `which rbenv` #{rbenv_bootstrap}"
|
|
23
|
+
end
|
|
24
|
+
after "deploy:install", "rbenv:install"
|
|
25
|
+
|
|
26
|
+
desc "Install Ruby in rbenv"
|
|
27
|
+
task :ruby, roles: [:app, :web] do
|
|
28
|
+
run "rbenv install #{ruby_version}"
|
|
29
|
+
run "rbenv global #{ruby_version}"
|
|
30
|
+
run "rbenv rehash"
|
|
31
|
+
end
|
|
32
|
+
desc "Install Bundler in rbenv"
|
|
33
|
+
task :bundler, roles: [:app, :web] do
|
|
34
|
+
run "gem install bundler --no-ri --no-rdoc"
|
|
35
|
+
run "rbenv rehash"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
after "rbenv:install", "rbenv:install:ruby"
|
|
39
|
+
after "rbenv:install:ruby", "rbenv:install:bundler"
|
|
40
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
set_default :redis_port, 6379
|
|
2
|
+
|
|
3
|
+
namespace :redis do
|
|
4
|
+
desc "Install redis server."
|
|
5
|
+
task :install, roles: [:app, :web] do
|
|
6
|
+
run "#{sudo} apt-get -y install redis-server"
|
|
7
|
+
end
|
|
8
|
+
desc 'Setup redis master'
|
|
9
|
+
task :setup_master, roles: :app, only: {primary: true} do
|
|
10
|
+
set :redis_is_master, true
|
|
11
|
+
template "redis_conf.erb", "/tmp/redis_conf"
|
|
12
|
+
run "#{sudo} mv /tmp/redis_conf /etc/redis/redis.conf"
|
|
13
|
+
end
|
|
14
|
+
desc 'Setup redis slaves'
|
|
15
|
+
task :setup_slaves, roles: :web do
|
|
16
|
+
set :redis_master, roles[:app].servers.detect{ |server| server.options[:primary] == true }
|
|
17
|
+
set :redis_is_master, false
|
|
18
|
+
template "redis_conf.erb", "/tmp/redis_conf"
|
|
19
|
+
run "#{sudo} mv /tmp/redis_conf /etc/redis/redis.conf"
|
|
20
|
+
end
|
|
21
|
+
after "deploy:install", "redis:install"
|
|
22
|
+
after "deploy:setup", "redis:setup_master"
|
|
23
|
+
after "deploy:setup", "redis:setup_slaves"
|
|
24
|
+
|
|
25
|
+
%w[start stop restart].each do |command|
|
|
26
|
+
desc "#{command} redis"
|
|
27
|
+
task command, roles: [:app, :web] do
|
|
28
|
+
run "#{sudo} service redis-server #{command}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "teknobingo_recipes/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "teknobingo-recipes"
|
|
7
|
+
s.version = TeknobingoRecipes::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["Patrick Hanevold"]
|
|
10
|
+
s.email = ["patrick@teknobingo.net"]
|
|
11
|
+
s.homepage = ""
|
|
12
|
+
s.summary = %q{Teknobingo capistrano recipes}
|
|
13
|
+
s.description = %q{Whole lot of recipes}
|
|
14
|
+
|
|
15
|
+
s.required_rubygems_version = ">= 1.3.7"
|
|
16
|
+
|
|
17
|
+
s.files = `git ls-files`.split("\n")
|
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
20
|
+
s.require_paths = ["lib"]
|
|
21
|
+
s.extra_rdoc_files = [
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"README.rdoc"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
s.add_dependency "colorize", ">= 0.5.8"
|
|
27
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
alias lesslog=<%= "'less ~/sites/#{application}/shared/log/#{branch}.log'" %>
|