conversion

This commit is contained in:
Nicolas Bally 2019-05-16 09:25:39 +02:00
parent 829a432d71
commit ea6bb78c2d
5 changed files with 144 additions and 91 deletions

View File

@ -1,26 +1,26 @@
set :application, 'ecole_eft_app'
set :domain, '62.210.187.249'
set :domain, 'quartz-www02.sysnove.net'
set :user, 'web'
set :scm_user, "git"
set :scm_host, "git.nicolasbally.com"
set :scm_host, "quartz.snlab.fr"
set :rvm_ruby_string, 'ruby-2.0.0-p195'
set :rvm_ruby_string, 'ruby-2.0.0-p648'
set :rvm_autolibs_flag, "read-only"
set :bundle_cmd, "/home/#{user}/.rvm/gems/#{rvm_ruby_string}@global/bin/bundle"
set :bundle_dir, "/home/#{user}/.rvm/gems/#{rvm_ruby_string}"
set :bundle_cmd, "/srv/www/#{user}/.rvm/gems/#{rvm_ruby_string}@global/bin/bundle"
set :bundle_dir, "/srv/www/#{user}/.rvm/gems/#{rvm_ruby_string}"
set :use_sudo, false
set :deploy_to, "/home/#{user}/#{application}/"
set :deploy_to, "/srv/www/#{user}/#{application}/"
set :deploy_via, :remote_cache
set :normalize_asset_timestamps, false
@ -33,7 +33,7 @@ role :db, domain, :primary => true
set :scm, :git
set :repository, "#{scm_user}@#{scm_host}:root/ecole-eft.git"
set :repository, "#{scm_user}@#{scm_host}:nicolas/#{application}.git"
set :branch, "master"
@ -49,7 +49,7 @@ require 'bundler/capistrano'
load 'deploy/assets'
namespace :deploy do
# namespace :assets do
# task :precompile, :roles => :web, :except => { :no_release => true } do
# from = source.next_revision(current_revision)
@ -60,42 +60,47 @@ namespace :deploy do
# end
# end
# end
desc "Symlink shared config files"
task :symlink_config_files do
run "ln -s #{deploy_to}shared/storage/private #{current_path}/private_medias"
run "ln -s #{deploy_to}shared/storage/public #{current_path}/public/public_medias"
run "ln -s #{deploy_to}shared/production.sqlite3 #{current_path}/db/production.sqlite3"
sudo "cp #{current_path}/config/env_init #{deploy_to}env_init"
sudo "cp #{current_path}/config/unicorn_init_d /etc/init.d/#{application}"
sudo "sudo systemctl enable quartz_app@#{application}"
sudo "chmod +x /etc/init.d/#{application}"
sudo "update-rc.d #{application} defaults "
end
task :start do
sudo "service #{application} start"
sudo "systemctl start quartz_app@#{application}"
end
task :stop do
run "service #{application} stop"
sudo "systemctl stop quartz_app@#{application}"
end
task :restart do
sudo "service #{application} restart"
sudo "systemctl stop quartz_app@#{application}"
sudo "systemctl start quartz_app@#{application}"
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
@ -105,24 +110,24 @@ namespace :deploy do
run "cd #{deploy_to}current && rake db:seed RAILS_ENV=#{rails_env}"
end
task :create_files_folders do
run "mkdir #{deploy_to}shared/storage"
run "mkdir #{deploy_to}shared/storage/private"
run "mkdir #{deploy_to}shared/storage/public"
end
end
#before 'deploy:setup', 'rvm:install_rvm' # install RVM
#before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset, OR:
#before 'deploy:setup', 'rvm:create_gemset' # only create gemset
after "deploy:setup", "deploy:create_files_folders"
@ -135,4 +140,7 @@ before "deploy:restart", "deploy:symlink_config_files"
after "deploy", "deploy:cleanup"

6
config/env_init Normal file
View File

@ -0,0 +1,6 @@
APP_RUBY=2.0.0-p648
ENV=production
APP_ROOT=/srv/www/web/ecole_eft_app/current/
GEM_HOME=/srv/www/web/.rvm/gems/ruby-$APP_RUBY
UNICORN_OPTS="-D -E ${ENV} -c ${APP_ROOT}/config/unicorn.rb"

View File

@ -1,11 +1,11 @@
upstream ecole_eft_app_unicorn {
server unix:/home/web/ecole_eft_app/shared/unicorn.sock fail_timeout=0;
server unix:/srv/www/web/ecole_eft_app/shared/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name new.ecole-eft-france.fr;
root /home/web/ecole_eft_app/current/public;
listen [::]:443 ssl;
server_name ecole-eft-france.fr arreter-de-fumer-avec-eft.com;
root /srv/www/web/ecole_eft_app/current/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
@ -13,61 +13,100 @@ server {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://ecole_eft_app_unicorn;
proxy_read_timeout 6000;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
server {
listen 80;
server_name ecole-eft-france.fr www.ecole-eft-france.fr;
rewrite ^(.*) https://ecole-eft-france.fr$1 permanent;
}
server {
listen 443 ssl;
server_name ecole-eft-france.fr;
root /home/web/ecole_eft_app/current/public;
ssl on;
ssl_certificate /etc/nginx/ssl/ecole_eft_app/monserveur.crt;
ssl_certificate_key /etc/nginx/ssl/ecole_eft_app/monserveur.key;
try_files $uri/index.html $uri @unicorn;
#access_log /var/log/nginx/YOUR_APP_NAME_access.log combined;
#error_log /var/log/nginx/YOUR_APP_NAME_error.log;
location @unicorn {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://ecole_eft_app_unicorn;
proxy_set_header X-Forwarded-Proto https;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
server {
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl/ecole_eft_app/monserveur.crt;
ssl_certificate_key /etc/nginx/ssl/ecole_eft_app/monserveur.key;
ssl_certificate /etc/letsencrypt/live/ecole-eft-france.fr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ecole-eft-france.fr/privkey.pem;
server_name *.ecole-eft-france.fr www.ecole-eft-france.fr;
rewrite ^(.*) https://ecole-eft-france.fr$1 permanent;
include snippets/letsencrypt.conf;
}
server {
listen [::]:443 ssl;
server_name www.arreter-de-fumer-avec-eft.com ;
ssl on;
ssl_certificate /etc/letsencrypt/live/ecole-eft-france.fr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ecole-eft-france.fr/privkey.pem;
return 301 https://arreter-de-fumer-avec-eft.com$request_uri;
include snippets/letsencrypt.conf;
}
server {
listen [::]:443 ssl;
server_name www.ecole-eft-france.fr *.techniques-eft.org *.techniques-eft.info *.techniques-eft.fr *.techniques-eft.eu techniques-eft.org techniques-eft.info techniques-eft.fr techniques-eft.eu ;
ssl on;
ssl_certificate /etc/letsencrypt/live/ecole-eft-france.fr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ecole-eft-france.fr/privkey.pem;
return 301 https://ecole-eft-france.fr$request_uri;
include snippets/letsencrypt.conf;
}
server {
listen [::]:80;
server_name te.quartz.xyz;
root /srv/www/web/ecole_eft_app/current/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://ecole_eft_app_unicorn;
proxy_read_timeout 6000;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
include snippets/letsencrypt.conf;
}
server {
listen [::]:443 ssl;
server_name www.ecole-eft-france.fr *.techniques-eft.org *.techniques-eft.info *.techniques-eft.fr *.techniques-eft.eu techniques-eft.org techniques-eft.info techniques-eft.fr techniques-eft.eu ;
ssl on;
ssl_certificate /etc/letsencrypt/live/ecole-eft-france.fr/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ecole-eft-france.fr/privkey.pem;
return 301 https://ecole-eft-france.fr$request_uri;
include snippets/letsencrypt.conf;
}
server {
listen [::]:80;
server_name arreter-de-fumer-avec-eft.com *.arreter-de-fumer-avec-eft.com www.arreter-de-fumer-avec-eft.com arreter-de-fumer.bally.me;
return 301 https://arreter-de-fumer-avec-eft.com$request_uri;
include snippets/letsencrypt.conf;
}
server {
listen [::]:80;
server_name ecole-eft-france.fr www.ecole-eft-france.fr eft.bally.me *.techniques-eft.org *.techniques-eft.info *.techniques-eft.fr *.techniques-eft.eu techniques-eft.org techniques-eft.info techniques-eft.fr techniques-eft.eu ;
return 301 https://ecole-eft-france.fr$request_uri;
include snippets/letsencrypt.conf;
}

View File

@ -1,10 +1,10 @@
@rails_app = "ecole_eft_app"
working_directory "/home/web/#{@rails_app}/current"
pid "/home/web/#{@rails_app}/shared/unicorn.pid"
stderr_path "/home/web/#{@rails_app}/shared/unicorn.log"
stdout_path "/home/web/#{@rails_app}/shared/unicorn.log"
working_directory "/srv/www/web/#{@rails_app}/current"
pid "/srv/www/web/#{@rails_app}/shared/unicorn.pid"
stderr_path "/srv/www/web/#{@rails_app}/shared/log/unicorn.log"
stdout_path "/srv/www/web/#{@rails_app}/shared/log/unicorn.log"
listen "/home/web/#{@rails_app}/shared/unicorn.sock"
listen "/srv/www/web/#{@rails_app}/shared/tmp/unicorn.sock"
worker_processes 2
timeout 30
timeout 600

10
config/unicorn_init_d Normal file → Executable file
View File

@ -6,17 +6,17 @@ set -e
# Change these to match your app:
APP_NAME=ecole_eft_app
APP_RUBY=2.0.0-p195
APP_ROOT="/home/web/ecole_eft_app/current"
PID="/home/web/ecole_eft_app/shared/unicorn.pid"
APP_RUBY=ruby-2.0.0-p648
APP_ROOT="/srv/www/web/ecole_eft_app/current"
PID="/srv/www/web/ecole_eft_app/shared/unicorn.pid"
ENV=production
GEM_HOME="/home/web/.rvm/gems/ruby-$APP_RUBY"
GEM_HOME="/srv/www/web/.rvm/gems/ruby-$APP_RUBY"
UNICORN_OPTS="-D -E $ENV -c $APP_ROOT/config/unicorn.rb"
SET_PATH="cd $APP_ROOT; rvm $APP_RUBY"
CMD="$SET_PATH; unicorn $UNICORN_OPTS"
CMD="$SET_PATH; bundle exec unicorn $UNICORN_OPTS"
old_pid="$PID.oldbin"