nouveau serveur

This commit is contained in:
Nicolas Bally 2015-05-18 01:43:53 +02:00
parent 1cbfc07861
commit a9cb75c2c2
6 changed files with 148 additions and 65 deletions

View File

@ -22,7 +22,7 @@ gem 'jquery-rails'
# Deploy with Capistrano # Deploy with Capistrano
gem 'capistrano' gem 'capistrano'
gem 'rvm-capistrano' gem "rvm-capistrano"
# To use debugger # To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug' # gem 'ruby-debug19', :require => 'ruby-debug'

View File

@ -30,14 +30,16 @@ GEM
activesupport (= 3.1.0) activesupport (= 3.1.0)
activesupport (3.1.0) activesupport (3.1.0)
multi_json (~> 1.0) multi_json (~> 1.0)
acts_as_list (0.1.4) acts_as_list (0.2.0)
acts_as_tree (0.1.1) activerecord (>= 3.0)
ansi (1.4.2) acts_as_tree (1.2.0)
arel (2.2.1) activerecord (>= 3.0.0)
ansi (1.4.3)
arel (2.2.3)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
builder (3.0.0) builder (3.0.4)
cancan (1.6.7) cancan (1.6.9)
capistrano (2.13.3) capistrano (2.14.2)
highline highline
net-scp (>= 1.0.0) net-scp (>= 1.0.0)
net-sftp (>= 2.0.0) net-sftp (>= 2.0.0)
@ -48,32 +50,32 @@ GEM
coffee-script (2.2.0) coffee-script (2.2.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.2.0) coffee-script-source (1.6.2)
devise (2.0.1) devise (2.2.3)
bcrypt-ruby (~> 3.0) bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3) orm_adapter (~> 0.1)
railties (~> 3.1) railties (~> 3.1)
warden (~> 1.1) warden (~> 1.2.1)
erubis (2.7.0) erubis (2.7.0)
execjs (1.3.0) execjs (1.4.0)
multi_json (~> 1.0) multi_json (~> 1.0)
formtastic (2.0.2) formtastic (2.2.1)
rails (~> 3.0) actionpack (>= 3.0)
haml (3.1.4) haml (4.0.1)
highline (1.6.13) tilt
highline (1.6.16)
hike (1.2.1) hike (1.2.1)
i18n (0.6.0) i18n (0.6.4)
jquery-rails (1.0.19) jquery-rails (2.2.1)
railties (~> 3.0) railties (>= 3.0, < 5.0)
thor (~> 0.14) thor (>= 0.14, < 2.0)
json (1.6.5) json (1.7.7)
kaminari (0.13.0) kaminari (0.14.1)
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
railties (>= 3.0.0) kgio (2.8.0)
kgio (2.7.2) libv8 (3.11.8.17)
libv8 (3.3.10.4) mail (2.3.3)
mail (2.3.0)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
@ -82,29 +84,29 @@ GEM
activerecord (~> 3.1) activerecord (~> 3.1)
activesupport (~> 3.1) activesupport (~> 3.1)
polyamorous (~> 0.5.0) polyamorous (~> 0.5.0)
mime-types (1.17.2) mime-types (1.21)
mimetype-fu (0.1.2) mimetype-fu (0.1.2)
multi_json (1.0.4) multi_json (1.7.2)
mysql2 (0.3.11) mysql2 (0.3.11)
net-scp (1.0.4) net-scp (1.1.0)
net-ssh (>= 1.99.1) net-ssh (>= 2.6.5)
net-sftp (2.0.5) net-sftp (2.1.1)
net-ssh (>= 2.0.9) net-ssh (>= 2.6.5)
net-ssh (2.5.2) net-ssh (2.6.6)
net-ssh-gateway (1.1.0) net-ssh-gateway (1.2.0)
net-ssh (>= 1.99.1) net-ssh (>= 2.6.5)
orm_adapter (0.0.6) orm_adapter (0.4.0)
polyamorous (0.5.0) polyamorous (0.5.0)
activerecord (~> 3.0) activerecord (~> 3.0)
polyglot (0.3.3) polyglot (0.3.3)
rack (1.3.6) rack (1.3.10)
rack-cache (1.0.3) rack-cache (1.0.3)
rack (>= 0.4) rack (>= 0.4)
rack-mount (0.8.3) rack-mount (0.8.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-ssl (1.3.2) rack-ssl (1.3.3)
rack rack
rack-test (0.6.1) rack-test (0.6.2)
rack (>= 1.0) rack (>= 1.0)
rails (3.1.0) rails (3.1.0)
actionmailer (= 3.1.0) actionmailer (= 3.1.0)
@ -121,46 +123,48 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (~> 0.14.6) thor (~> 0.14.6)
raindrops (0.8.0) raindrops (0.10.0)
rake (0.9.2.2) rake (10.0.3)
rdoc (3.12) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
rmagick (2.13.1) ref (1.0.4)
rvm-capistrano (1.2.5) rmagick (2.13.2)
rvm-capistrano (1.2.7)
capistrano (>= 2.0.0) capistrano (>= 2.0.0)
sass (3.1.14) sass (3.2.7)
sass-rails (3.1.5) sass-rails (3.1.7)
actionpack (~> 3.1.0) actionpack (~> 3.1.0)
railties (~> 3.1.0) railties (~> 3.1.0)
sass (~> 3.1.10) sass (>= 3.1.10)
tilt (~> 1.3.2) tilt (~> 1.3.2)
simple-navigation (3.6.0) simple-navigation (3.10.0)
activesupport (>= 2.3.2) activesupport (>= 2.3.2)
sprockets (2.0.3) sprockets (2.0.4)
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5) sqlite3 (1.3.7)
therubyracer (0.9.9) therubyracer (0.11.4)
libv8 (~> 3.3.10) libv8 (~> 3.11.8.12)
ref
thor (0.14.6) thor (0.14.6)
tilt (1.3.3) tilt (1.3.6)
treetop (1.4.10) treetop (1.4.12)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
turn (0.9.2) turn (0.9.6)
ansi ansi
tzinfo (0.3.31) tzinfo (0.3.37)
uglifier (1.2.3) uglifier (1.3.0)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (>= 1.0.2) multi_json (~> 1.0, >= 1.0.2)
unicorn (4.2.0) unicorn (4.6.2)
kgio (~> 2.6) kgio (~> 2.6)
rack rack
raindrops (~> 0.7) raindrops (~> 0.7)
warden (1.1.0) warden (1.2.1)
rack (>= 1.0) rack (>= 1.0)
yaml_db (0.2.2) yaml_db (0.2.3)
PLATFORMS PLATFORMS
ruby ruby

View File

@ -28,7 +28,7 @@ set :application, 'boissier_app'
role :db, domain, :primary => true role :db, domain, :primary => true
set :scm, :git set :scm, :git
set :repository, "git@box1.quartz-agence.com:#{application}.git" set :repository, "git@git.nicolasbally.com:root/boissier_app.git"
set :branch, "master" set :branch, "master"
default_run_options[:pty] = true default_run_options[:pty] = true
@ -45,11 +45,26 @@ set :application, 'boissier_app'
run "cd #{deploy_to}current && bundle install" run "cd #{deploy_to}current && bundle install"
end end
task :reload_nginx do
sudo "rm -rf /etc/nginx/sites-enabled/#{application}"
sudo "ln -s #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application} "
sudo "service nginx reload"
end
task :make_simlinks do task :make_simlinks do
run "rm -rf #{deploy_to}current/private_medias" run "rm -rf #{deploy_to}current/private_medias"
run "ln -s #{deploy_to}shared/storage/private #{deploy_to}current/private_medias" run "ln -s #{deploy_to}shared/storage/private #{deploy_to}current/private_medias"
run "rm -rf #{deploy_to}current/public/public_medias" run "rm -rf #{deploy_to}current/public/public_medias"
run "ln -s #{deploy_to}shared/storage/public #{deploy_to}current/public/public_medias" run "ln -s #{deploy_to}shared/storage/public #{deploy_to}current/public/public_medias"
sudo "cp #{current_path}/config/unicorn_init_d /etc/init.d/#{application}"
sudo "chmod +x /etc/init.d/#{application}"
sudo "update-rc.d #{application} defaults "
end end
task :start do task :start do

View File

@ -1,5 +1,5 @@
upstream boissier_app_unicorn { upstream boissier_app_unicorn {
server unix:/home/web/boissier_app/shared/tmp/unicorn.sock fail_timeout=0; server unix:/home/web/boissier_app/shared/unicorn.sock fail_timeout=0;
} }
server { server {

View File

@ -5,6 +5,6 @@ pid "/home/web/#{@rails_app}/shared/unicorn.pid"
stderr_path "/home/web/#{@rails_app}/shared/log/unicorn.log" stderr_path "/home/web/#{@rails_app}/shared/log/unicorn.log"
stdout_path "/home/web/#{@rails_app}/shared/log/unicorn.log" stdout_path "/home/web/#{@rails_app}/shared/log/unicorn.log"
listen "/home/web/#{@rails_app}/shared/tmp/unicorn.sock" listen "/home/web/#{@rails_app}/shared/unicorn.sock"
worker_processes 2 worker_processes 2
timeout 30 timeout 30

64
config/unicorn_init_d Executable file
View File

@ -0,0 +1,64 @@
#!/bin/bash
set -u
set -e
# Change these to match your app:
APP_NAME=boissier_app
APP_RUBY=1.9.3-p0
APP_ROOT="/home/web/boissier_app/current"
PID="/home/web/boissier_app/shared/unicorn.pid"
ENV=production
GEM_HOME="/home/web/.rvm/gems/ruby-$APP_RUBY"
UNICORN_OPTS="-D -E $ENV -c $APP_ROOT/config/unicorn.rb"
SET_PATH="cd $APP_ROOT; rvm 1.9.3-p0"
CMD="$SET_PATH; unicorn $UNICORN_OPTS"
old_pid="$PID.oldbin"
cd $APP_ROOT || exit 1
sig () {
test -s "$PID" && kill -$1 `cat $PID`
}
oldsig () {
test -s $old_pid && kill -$1 `cat $old_pid`
}
case ${1-help} in
start)
sig 0 && echo >&2 "Already running" && exit 0
su - web -c "$CMD"
;;
stop)
sig QUIT && exit 0
echo >&2 "Not running"
;;
force-stop)
sig TERM && exit 0
echo >&2 "Not running"
;;
restart|reload)
sig HUP && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
su - web -c "$CMD"
;;
upgrade)
sig USR2 && exit 0
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
su - web -c "$CMD"
;;
rotate)
sig USR1 && echo rotated logs OK && exit 0
echo >&2 "Couldn't rotate logs" && exit 1
;;
*)
echo >&2 "Usage: $0 "
exit 1
;;
esac