rob_cap_recipes 0.0.4.alpha2 → 0.0.5.alpha1
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 +4 -4
- data/lib/rob_cap_recipes/recipes/base.cap +25 -0
- data/lib/rob_cap_recipes/recipes/check.cap +14 -0
- data/lib/rob_cap_recipes/recipes/common.rb +4 -5
- data/lib/rob_cap_recipes/recipes/mysql.cap +29 -0
- data/lib/rob_cap_recipes/recipes/nginx.cap +31 -0
- data/lib/rob_cap_recipes/recipes/nodejs.cap +11 -0
- data/lib/rob_cap_recipes/recipes/puma.cap +11 -0
- data/lib/rob_cap_recipes/recipes/rbenv.cap +48 -0
- data/lib/rob_cap_recipes/recipes/templates/mysql.yml.erb +12 -12
- data/lib/rob_cap_recipes/recipes/templates/nginx.erb +6 -6
- data/lib/rob_cap_recipes/recipes/unicorn.cap +26 -0
- data/lib/rob_cap_recipes/recipes.rb +16 -8
- data/lib/rob_cap_recipes/version.rb +1 -1
- metadata +10 -10
- data/lib/rob_cap_recipes/recipes/base.rb +0 -31
- data/lib/rob_cap_recipes/recipes/check.rb +0 -16
- data/lib/rob_cap_recipes/recipes/mysql.rb +0 -30
- data/lib/rob_cap_recipes/recipes/nginx.rb +0 -28
- data/lib/rob_cap_recipes/recipes/nodejs.rb +0 -11
- data/lib/rob_cap_recipes/recipes/puma.rb +0 -35
- data/lib/rob_cap_recipes/recipes/rbenv.rb +0 -50
- data/lib/rob_cap_recipes/recipes/unicorn.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0671a3f566bf32275c92e7fe55a996e991b8ec69
|
4
|
+
data.tar.gz: 645b61171af673fb9d40f25cacf04b8aff1592db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 570cba97c7f7840e03a11898f307b0742b255c0c1b66ba2f12a6c46908fd459ca92ea43d43af96a10bd6cd6b41408cab789c0f544be338dcdef9f2d231aa1a87
|
7
|
+
data.tar.gz: be8b68673e39e9020616fcb4aac276d02c4ef43bdbe556ff5ad0f26a82f4343ac665bcf6c50d270fa5563e8052816262f1fd0439646cc2d47c817ea1c85b7a15
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rob_cap_recipes/recipes/common'
|
2
|
+
|
3
|
+
unless fetch(:application)
|
4
|
+
abort "pleas specify the name of youre application: set :application, 'AppName'"
|
5
|
+
end
|
6
|
+
|
7
|
+
set :scm, :git
|
8
|
+
set :repo_url, "git@gitlab.stridsberg.nu:ruby_#{fetch(:application).downcase}.git"
|
9
|
+
set :branch, 'master'
|
10
|
+
|
11
|
+
set :use_sudo, false
|
12
|
+
set :keep_releases, 5
|
13
|
+
|
14
|
+
namespace :deploy do
|
15
|
+
task :install do
|
16
|
+
on roles( :all ) do
|
17
|
+
sudo "apt-get update"
|
18
|
+
sudo "apt-get install python-software-properties -y"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
after "deploy", "deploy:migrate"
|
23
|
+
|
24
|
+
after "deploy:symlink:linked_dirs", "deploy:symlink:release"
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
namespace :check do
|
2
|
+
desc "Make sure local git is in sync with remote."
|
3
|
+
task :revision do
|
4
|
+
on roles( :web) do
|
5
|
+
unless `git rev-parse HEAD` == `git rev-parse origin/#{fetch(:branch)}`
|
6
|
+
puts "WARNING: HEAD is not the same as origin/#{fetch(:branch)}"
|
7
|
+
puts "if you are on another branch use caps deploy -s branch='current_branch'"
|
8
|
+
puts "Run `git push` to sync changes."
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
before "deploy", "check:revision"
|
14
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
def template(from, to)
|
2
2
|
erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
set(name, *args, &block) unless exists?(name)
|
3
|
+
str = StringIO.new(ERB.new(erb).result(binding))
|
4
|
+
on roles(:app) do |host|
|
5
|
+
upload!(str, to)
|
6
|
+
end
|
8
7
|
end
|
9
8
|
|
10
9
|
def add_apt_repository(repo)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
namespace :mysql do
|
2
|
+
set(:mysql_host, "saga.stridsberg.nu")
|
3
|
+
|
4
|
+
|
5
|
+
set :linked_files, %w{config/database.yml}
|
6
|
+
|
7
|
+
ask(:mysql_user,"" )
|
8
|
+
ask(:mysql_password,"")
|
9
|
+
|
10
|
+
|
11
|
+
task :install do
|
12
|
+
on roles(:web) do
|
13
|
+
sudo "apt-get update -y"
|
14
|
+
sudo "apt-get install -y libmysql-ruby libmysqlclient-dev"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
after "deploy:install", "mysql:install"
|
18
|
+
|
19
|
+
task :setup do
|
20
|
+
on roles( :app ) do
|
21
|
+
# execute %{mkdir -pv "#{shared_path}/config"}
|
22
|
+
execute :mkdir, '-pv', "#{shared_path}/config"
|
23
|
+
unless File.exist?("#{shared_path}/config/database.yml")
|
24
|
+
template "mysql.yml.erb", "#{shared_path}/config/database.yml"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
after "mysql:install", "mysql:setup"
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
namespace :nginx do
|
2
|
+
desc "Install latest stable release of nginx"
|
3
|
+
|
4
|
+
task :install do
|
5
|
+
on roles(:web) do
|
6
|
+
#add_apt_repository 'ppa:nginx/stable'
|
7
|
+
sudo "apt-get update"
|
8
|
+
sudo "apt-get install nginx -y"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
after "deploy:install", "nginx:install"
|
12
|
+
|
13
|
+
desc "Setup nginx configuration for this application"
|
14
|
+
task :setup do
|
15
|
+
on roles(:web) do
|
16
|
+
template "nginx.erb", "/tmp/nginx_conf"
|
17
|
+
sudo "mv /tmp/nginx_conf /etc/nginx/sites-enabled/#{fetch(:application)}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
after "nginx:install", "nginx:setup"
|
21
|
+
|
22
|
+
%w[start stop restart].each do |command|
|
23
|
+
desc "#{command} nginx"
|
24
|
+
task command do
|
25
|
+
on roles( :web) do
|
26
|
+
sudo "service nginx #{command}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
after "nginx:setup", "nginx:restart"
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :nodejs do
|
2
|
+
desc 'Install the latest relase of Node.js'
|
3
|
+
task :install do
|
4
|
+
on roles( :app) do
|
5
|
+
#add_apt_repository 'ppa:chris-lea/node.js'
|
6
|
+
sudo "apt-get update"
|
7
|
+
sudo "apt-get install nodejs -y"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
after "deploy:install", "nodejs:install"
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :puma do
|
2
|
+
set(:puma_user, fetch(:user) )
|
3
|
+
# set :puma_pid, -> { File.join(shared_path, 'tmp', 'pids', 'puma.pid') }
|
4
|
+
|
5
|
+
task :setup do
|
6
|
+
on roles( :app ) do
|
7
|
+
execute :mkdir, '-pv', "#{shared_path}/tmp/pids", "#{shared_path}/tmp/sockets", "#{shared_path}/config", "#{shared_path}/log"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
after "deploy:install", "puma:setup"
|
11
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
namespace :rbenv do
|
2
|
+
|
3
|
+
set :ruby_version, "1.9.3-p429"
|
4
|
+
set :rbenv_bootstrap, "bootstrap-ubuntu-12-04"
|
5
|
+
|
6
|
+
|
7
|
+
desc "Install rbenv, Ruby, and the Bundler gem"
|
8
|
+
task :install, roles: :app 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
|
+
rbenv "#{rbenv_bootstrap}"
|
23
|
+
rbenv "install #{ruby_version}"
|
24
|
+
rbenv "global #{ruby_version}"
|
25
|
+
run "gem install bundler --no-ri --no-rdoc"
|
26
|
+
run "rbenv rehash"
|
27
|
+
end
|
28
|
+
after "deploy:install", "rbenv:install"
|
29
|
+
end
|
30
|
+
|
31
|
+
def rbenv(command)
|
32
|
+
# possible override flag if a exception is raised
|
33
|
+
success = false
|
34
|
+
begin
|
35
|
+
run "rbenv #{command}", :pty => true do |ch, stream, data|
|
36
|
+
if data =~ /\[sudo\].password.for/
|
37
|
+
ch.send_data("#{password}\n")
|
38
|
+
elsif data =~ /\install/
|
39
|
+
success = true
|
40
|
+
ch.send_data("n\n")
|
41
|
+
else
|
42
|
+
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
rescue
|
46
|
+
raise unless success
|
47
|
+
end
|
48
|
+
end
|
@@ -2,28 +2,28 @@ development:
|
|
2
2
|
adapter: mysql2
|
3
3
|
encoding: utf8
|
4
4
|
reconnect: false
|
5
|
-
database: <%= application %>_development
|
5
|
+
database: <%= fetch(:application) %>_development
|
6
6
|
pool: 5
|
7
|
-
username: <%= mysql_user %>
|
8
|
-
password: <%= mysql_password %>
|
9
|
-
|
7
|
+
username: <%= fetch(:mysql_user) %>
|
8
|
+
password: <%= fetch(:mysql_password) %>
|
9
|
+
host: <%= fetch(:mysql_host) %>
|
10
10
|
|
11
11
|
test:
|
12
12
|
adapter: mysql2
|
13
13
|
encoding: utf8
|
14
14
|
reconnect: false
|
15
|
-
database: <%= application %>_test
|
15
|
+
database: <%= fetch(:application) %>_test
|
16
16
|
pool: 5
|
17
|
-
username: <%= mysql_user %>
|
18
|
-
password: <%= mysql_password %>
|
19
|
-
|
17
|
+
username: <%= fetch(:mysql_user) %>
|
18
|
+
password: <%= fetch(:mysql_password) %>
|
19
|
+
host: <%= fetch(:mysql_host) %>
|
20
20
|
|
21
21
|
production:
|
22
22
|
adapter: mysql2
|
23
23
|
encoding: utf8
|
24
24
|
reconnect: false
|
25
|
-
database: <%= application %>_production
|
25
|
+
database: <%= fetch(:application) %>_production
|
26
26
|
pool: 5
|
27
|
-
username: <%= mysql_user %>
|
28
|
-
password: <%= mysql_password %>
|
29
|
-
host: <%= mysql_host %>
|
27
|
+
username: <%= fetch(:mysql_user) %>
|
28
|
+
password: <%= fetch(:mysql_password) %>
|
29
|
+
host: <%= fetch(:mysql_host) %>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
upstream nginx.<%= host_header %> {
|
2
|
-
server <%= "
|
1
|
+
upstream nginx.<%= fetch(:host_header) %> {
|
2
|
+
server <%= fetch(:puma_bind)" %> fail_timeout=0;
|
3
3
|
}
|
4
4
|
|
5
5
|
server {
|
6
6
|
listen 80;
|
7
|
-
server_name <%= host_header %>;
|
7
|
+
server_name <%= fetch(:host_header) %>;
|
8
8
|
root <%= current_path %>/public;
|
9
9
|
|
10
10
|
location ^~ /assets/ {
|
@@ -13,12 +13,12 @@ server {
|
|
13
13
|
add_header Cache-Control public;
|
14
14
|
}
|
15
15
|
|
16
|
-
try_files $uri/index.html $uri @<%= application %>;
|
17
|
-
location @<%= application %> {
|
16
|
+
try_files $uri/index.html $uri @<%= fetch(:application) %>;
|
17
|
+
location @<%= fetch(:application) %> {
|
18
18
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
19
19
|
proxy_set_header Host $http_host;
|
20
20
|
proxy_redirect off;
|
21
|
-
proxy_pass http://nginx.<%=host_header
|
21
|
+
proxy_pass http://nginx.<%=fetch(:host_header)%>;
|
22
22
|
}
|
23
23
|
|
24
24
|
error_page 500 502 503 504 /500.html;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
namespace :unicorn do
|
2
|
+
set (:unicorn_user, fetch(:user))
|
3
|
+
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
|
4
|
+
set :unicorn_config, "#{shared_path}/config/unicorn.rb"
|
5
|
+
set :unicorn_log, "#{shared_path}/log/unicorn.log"
|
6
|
+
set:unicorn_workers, 2
|
7
|
+
|
8
|
+
desc "Setup Unicorn initializer and app configuration"
|
9
|
+
task :setup, roles: :app do
|
10
|
+
run "mkdir -p #{shared_path}/config"
|
11
|
+
template "unicorn.rb.erb", unicorn_config
|
12
|
+
template "unicorn_init.erb", "/tmp/unicorn_init"
|
13
|
+
run "chmod +x /tmp/unicorn_init"
|
14
|
+
run "#{sudo} mv /tmp/unicorn_init /etc/init.d/unicorn_#{application}"
|
15
|
+
run "#{sudo} update-rc.d -f unicorn_#{application} defaults"
|
16
|
+
end
|
17
|
+
after "deploy:setup", "unicorn:setup"
|
18
|
+
|
19
|
+
%w[start stop restart].each do |command|
|
20
|
+
desc "#{command} unicorn"
|
21
|
+
task command, roles: :app do
|
22
|
+
run "service unicorn_#{application} #{command}"
|
23
|
+
end
|
24
|
+
after "deploy:#{command}", "unicorn:#{command}"
|
25
|
+
end
|
26
|
+
end
|
@@ -1,8 +1,16 @@
|
|
1
|
-
require "rob_cap_recipes/recipes/base"
|
2
|
-
require "rob_cap_recipes/recipes/nginx"
|
3
|
-
require "rob_cap_recipes/recipes/puma"
|
4
|
-
|
5
|
-
require "rob_cap_recipes/recipes/nodejs"
|
6
|
-
require "rob_cap_recipes/recipes/rbenv"
|
7
|
-
require "rob_cap_recipes/recipes/check"
|
8
|
-
require 'rob_cap_recipes/recipes/mysql'
|
1
|
+
#require "rob_cap_recipes/recipes/base"
|
2
|
+
#require "rob_cap_recipes/recipes/nginx"
|
3
|
+
##require "rob_cap_recipes/recipes/puma"
|
4
|
+
##require "rob_cap_recipes/recipes/unicorn"
|
5
|
+
#require "rob_cap_recipes/recipes/nodejs"
|
6
|
+
##require "rob_cap_recipes/recipes/rbenv"
|
7
|
+
#require "rob_cap_recipes/recipes/check"
|
8
|
+
#require 'rob_cap_recipes/recipes/mysql'
|
9
|
+
load File.expand_path('../recipes/base.cap', __FILE__)
|
10
|
+
load File.expand_path('../recipes/nodejs.cap', __FILE__)
|
11
|
+
load File.expand_path('../recipes/check.cap', __FILE__)
|
12
|
+
load File.expand_path('../recipes/mysql.cap', __FILE__)
|
13
|
+
load File.expand_path('../recipes/nginx.cap', __FILE__)
|
14
|
+
load File.expand_path('../recipes/puma.cap', __FILE__)
|
15
|
+
#load File.expand_path('../recipes/unicorn.cap', __FILE__)
|
16
|
+
#load File.expand_path('../recipes/rbenv.cap', __FILE__)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rob_cap_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Stridsberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -39,14 +39,14 @@ files:
|
|
39
39
|
- lib/rob_cap_recipes.rb
|
40
40
|
- lib/rob_cap_recipes/railtie.rb
|
41
41
|
- lib/rob_cap_recipes/recipes.rb
|
42
|
-
- lib/rob_cap_recipes/recipes/base.
|
43
|
-
- lib/rob_cap_recipes/recipes/check.
|
42
|
+
- lib/rob_cap_recipes/recipes/base.cap
|
43
|
+
- lib/rob_cap_recipes/recipes/check.cap
|
44
44
|
- lib/rob_cap_recipes/recipes/common.rb
|
45
|
-
- lib/rob_cap_recipes/recipes/mysql.
|
46
|
-
- lib/rob_cap_recipes/recipes/nginx.
|
47
|
-
- lib/rob_cap_recipes/recipes/nodejs.
|
48
|
-
- lib/rob_cap_recipes/recipes/puma.
|
49
|
-
- lib/rob_cap_recipes/recipes/rbenv.
|
45
|
+
- lib/rob_cap_recipes/recipes/mysql.cap
|
46
|
+
- lib/rob_cap_recipes/recipes/nginx.cap
|
47
|
+
- lib/rob_cap_recipes/recipes/nodejs.cap
|
48
|
+
- lib/rob_cap_recipes/recipes/puma.cap
|
49
|
+
- lib/rob_cap_recipes/recipes/rbenv.cap
|
50
50
|
- lib/rob_cap_recipes/recipes/templates/mysql.yml.erb
|
51
51
|
- lib/rob_cap_recipes/recipes/templates/nginx.erb
|
52
52
|
- lib/rob_cap_recipes/recipes/templates/puma.rb.erb
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- lib/rob_cap_recipes/recipes/templates/puma_run.erb
|
55
55
|
- lib/rob_cap_recipes/recipes/templates/unicorn.rb.erb
|
56
56
|
- lib/rob_cap_recipes/recipes/templates/unicorn_init.erb
|
57
|
-
- lib/rob_cap_recipes/recipes/unicorn.
|
57
|
+
- lib/rob_cap_recipes/recipes/unicorn.cap
|
58
58
|
- lib/rob_cap_recipes/tasks/db.rake
|
59
59
|
- lib/rob_cap_recipes/version.rb
|
60
60
|
- rob_cap_recipes.gemspec
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'rob_cap_recipes/recipes/common'
|
2
|
-
|
3
|
-
Capistrano::Configuration.instance(true).load do
|
4
|
-
default_run_options[:pty] = true
|
5
|
-
|
6
|
-
_cset :stages, ["staging", "production"]
|
7
|
-
_cset :default_stage, "staging"
|
8
|
-
|
9
|
-
_cset(:application) { abort "pleas specify the name of youre application: set :application, 'AppName' " }
|
10
|
-
|
11
|
-
_cset :deploy_via, :remote_cache
|
12
|
-
|
13
|
-
_cset :scm, :git
|
14
|
-
set(:repository) { "git@gitlab.stridsberg.nu:ruby_#{application.downcase}.git" }
|
15
|
-
_cset(:branch) { `git rev-parse --abbrev-ref HEAD` }
|
16
|
-
|
17
|
-
_cset :use_sudo, false
|
18
|
-
_cset :keep_releases, 5
|
19
|
-
|
20
|
-
|
21
|
-
namespace :deploy do
|
22
|
-
task :install do
|
23
|
-
run "#{sudo} apt-get update -y"
|
24
|
-
run "#{sudo} apt-get install python-software-properties -y"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
after "deploy:update", "deploy:cleanup"
|
29
|
-
after "deploy", "deploy:migrate"
|
30
|
-
|
31
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(true).load do
|
2
|
-
namespace :check do
|
3
|
-
desc "Make sure local git is in sync with remote."
|
4
|
-
task :revision, roles: :web do
|
5
|
-
unless `git rev-parse HEAD` == `git rev-parse origin/#{branch}`
|
6
|
-
puts "WARNING: HEAD is not the same as origin/#{branch}"
|
7
|
-
puts "if you are on another branch use caps deploy -s branch='current_branch'"
|
8
|
-
puts "Run `git push` to sync changes."
|
9
|
-
exit
|
10
|
-
end
|
11
|
-
end
|
12
|
-
before "deploy", "check:revision"
|
13
|
-
before "deploy:migrations", "check:revision"
|
14
|
-
before "deploy:cold", "check:revision"
|
15
|
-
end
|
16
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(true).load do
|
2
|
-
|
3
|
-
_cset(:mysql_host, "saga.stridsberg.nu")
|
4
|
-
_cset(:mysql_user) { Capistrano::CLI.ui.ask( "MySql user: ") }
|
5
|
-
_cset(:mysql_password) { Capistrano::CLI.ui.ask( "MySql password: ") }
|
6
|
-
|
7
|
-
namespace :mysql do
|
8
|
-
|
9
|
-
task :install, roles: :db, only: {primary: true} do
|
10
|
-
run "#{sudo} apt-get update -y"
|
11
|
-
run "#{sudo} apt-get install -y mysql-server libmysql-ruby libmysqlclient-dev"
|
12
|
-
end
|
13
|
-
after "deploy:install", "mysql:install"
|
14
|
-
|
15
|
-
task :setup, roles: :app do
|
16
|
-
run "mkdir -p #{shared_path}/config"
|
17
|
-
unless File.exist?("#{shared_path}/config/database.yml")
|
18
|
-
template "mysql.yml.erb", "#{shared_path}/config/database.yml"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
after "deploy:setup", "mysql:setup"
|
22
|
-
|
23
|
-
|
24
|
-
desc "Symlink the database.yml file into latest release"
|
25
|
-
task :symlink, roles: :app do
|
26
|
-
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
27
|
-
end
|
28
|
-
after "deploy:finalize_update", "mysql:symlink"
|
29
|
-
end
|
30
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(true).load do
|
2
|
-
namespace :nginx do
|
3
|
-
desc "Install latest stable release of nginx"
|
4
|
-
|
5
|
-
task :install, roles: :web do
|
6
|
-
add_apt_repository 'ppa:nginx/stable'
|
7
|
-
run "#{sudo} apt-get -y update"
|
8
|
-
run "#{sudo} apt-get -y install nginx"
|
9
|
-
end
|
10
|
-
after "deploy:install", "nginx:install"
|
11
|
-
|
12
|
-
desc "Setup nginx configuration for this application"
|
13
|
-
task :setup, roles: :web do
|
14
|
-
template "nginx.erb", "/tmp/nginx_conf"
|
15
|
-
run "#{sudo} mv /tmp/nginx_conf /etc/nginx/sites-enabled/#{application}"
|
16
|
-
restart
|
17
|
-
end
|
18
|
-
after "deploy:setup", "nginx:setup"
|
19
|
-
|
20
|
-
%w[start stop restart].each do |command|
|
21
|
-
desc "#{command} nginx"
|
22
|
-
task command, roles: :web do
|
23
|
-
run "#{sudo} service nginx #{command}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
@@ -1,11 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(true).load do
|
2
|
-
namespace :nodejs do
|
3
|
-
desc "Install the latest relase of Node.js"
|
4
|
-
task :install, roles: :app do
|
5
|
-
add_apt_repository 'ppa:chris-lea/node.js'
|
6
|
-
run "#{sudo} apt-get -y update"
|
7
|
-
run "#{sudo} apt-get -y install nodejs"
|
8
|
-
end
|
9
|
-
after "deploy:install", "nodejs:install"
|
10
|
-
end
|
11
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(true).load do
|
2
|
-
_cset(:puma_user){user}
|
3
|
-
_cset(:puma_pid){ "#{current_path}/tmp/sockets/puma.pid" }
|
4
|
-
_cset(:puma_state){ "#{current_path}/tmp/sockets/puma.state" }
|
5
|
-
_cset(:puma_socket){ "#{current_path}/tmp/sockets/puma.sock" }
|
6
|
-
_cset(:puma_config){ "#{shared_path}/config/puma.rb" }
|
7
|
-
|
8
|
-
namespace :puma_robstr do
|
9
|
-
desc "Setup Puma initializer and app configuration"
|
10
|
-
task :setup, roles: :app do
|
11
|
-
run "mkdir -p #{shared_path}/config"
|
12
|
-
unless File.exist?(puma_config)
|
13
|
-
template "puma.rb.erb", puma_config
|
14
|
-
end
|
15
|
-
template "puma_init.erb", "/tmp/puma_init"
|
16
|
-
run "chmod +x /tmp/puma_init"
|
17
|
-
run "#{sudo} mv /tmp/puma_init /etc/init.d/puma"
|
18
|
-
run "#{sudo} update-rc.d -f puma defaults"
|
19
|
-
run "#{sudo} touch /etc/puma.conf"
|
20
|
-
template "puma_run.erb", "/tmp/run-puma"
|
21
|
-
run "chmod +x /tmp/run-puma"
|
22
|
-
run "#{sudo} mv /tmp/run-puma /usr/local/bin/run-puma"
|
23
|
-
end
|
24
|
-
after "deploy:setup", "puma_robstr:setup"
|
25
|
-
|
26
|
-
desc "Update puma configa and Symlink the puma files into latest release"
|
27
|
-
task :symlink, roles: :app do
|
28
|
-
run "ln -nfs #{shared_path}/config/puma.rb #{release_path}/config/puma.rb"
|
29
|
-
run "ln -nfs #{shared_path}/sockets #{release_path}/tmp/sockets"
|
30
|
-
run "#{sudo} /etc/init.d/puma remove #{current_path}"
|
31
|
-
run "#{sudo} /etc/init.d/puma add #{current_path} #{puma_user}"
|
32
|
-
end
|
33
|
-
after "deploy:symlink", "puma_robstr:symlink"
|
34
|
-
end
|
35
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(true).load do
|
2
|
-
|
3
|
-
_cset :ruby_version, "1.9.3-p429"
|
4
|
-
_cset :rbenv_bootstrap, "bootstrap-ubuntu-12-04"
|
5
|
-
|
6
|
-
|
7
|
-
namespace :rbenv do
|
8
|
-
desc "Install rbenv, Ruby, and the Bundler gem"
|
9
|
-
task :install, roles: :app do
|
10
|
-
run "#{sudo} apt-get -y install curl git-core"
|
11
|
-
run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
|
12
|
-
bashrc = <<-BASHRC
|
13
|
-
if [ -d $HOME/.rbenv ]; then
|
14
|
-
export PATH="$HOME/.rbenv/bin:$PATH"
|
15
|
-
eval "$(rbenv init -)"
|
16
|
-
fi
|
17
|
-
BASHRC
|
18
|
-
put bashrc, "/tmp/rbenvrc"
|
19
|
-
run "cat /tmp/rbenvrc ~/.bashrc > ~/.bashrc.tmp"
|
20
|
-
run "mv ~/.bashrc.tmp ~/.bashrc"
|
21
|
-
run %q{export PATH="$HOME/.rbenv/bin:$PATH"}
|
22
|
-
run %q{eval "$(rbenv init -)"}
|
23
|
-
rbenv "#{rbenv_bootstrap}"
|
24
|
-
rbenv "install #{ruby_version}"
|
25
|
-
rbenv "global #{ruby_version}"
|
26
|
-
run "gem install bundler --no-ri --no-rdoc"
|
27
|
-
run "rbenv rehash"
|
28
|
-
end
|
29
|
-
after "deploy:install", "rbenv:install"
|
30
|
-
end
|
31
|
-
|
32
|
-
def rbenv(command)
|
33
|
-
# possible override flag if a exception is raised
|
34
|
-
success = false
|
35
|
-
begin
|
36
|
-
run "rbenv #{command}", :pty => true do |ch, stream, data|
|
37
|
-
if data =~ /\[sudo\].password.for/
|
38
|
-
ch.send_data("#{password}\n")
|
39
|
-
elsif data =~ /\install/
|
40
|
-
success = true
|
41
|
-
ch.send_data("n\n")
|
42
|
-
else
|
43
|
-
Capistrano::Configuration.default_io_proc.call(ch, stream, data)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
rescue
|
47
|
-
raise unless success
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(true).load do
|
2
|
-
_cset(:unicorn_user) { user }
|
3
|
-
_cset(:unicorn_pid) { "#{current_path}/tmp/pids/unicorn.pid" }
|
4
|
-
_cset(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
|
5
|
-
_cset(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
|
6
|
-
_cset(:unicorn_workers, 2)
|
7
|
-
|
8
|
-
namespace :unicorn do
|
9
|
-
desc "Setup Unicorn initializer and app configuration"
|
10
|
-
task :setup, roles: :app do
|
11
|
-
run "mkdir -p #{shared_path}/config"
|
12
|
-
template "unicorn.rb.erb", unicorn_config
|
13
|
-
template "unicorn_init.erb", "/tmp/unicorn_init"
|
14
|
-
run "chmod +x /tmp/unicorn_init"
|
15
|
-
run "#{sudo} mv /tmp/unicorn_init /etc/init.d/unicorn_#{application}"
|
16
|
-
run "#{sudo} update-rc.d -f unicorn_#{application} defaults"
|
17
|
-
end
|
18
|
-
after "deploy:setup", "unicorn:setup"
|
19
|
-
|
20
|
-
%w[start stop restart].each do |command|
|
21
|
-
desc "#{command} unicorn"
|
22
|
-
task command, roles: :app do
|
23
|
-
run "service unicorn_#{application} #{command}"
|
24
|
-
end
|
25
|
-
after "deploy:#{command}", "unicorn:#{command}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|