This commit is contained in:
Nicolas Bally 2018-08-10 10:31:51 +02:00
parent 9b043ad756
commit 9aba4fbbe1
5 changed files with 86 additions and 70 deletions

View File

@ -27,5 +27,5 @@ production:
<<: *default
database: sideplace_app
username: sideplace_app
password: sideplace_prod
password: sideplace_app
socket: /var/run/mysqld/mysqld.sock

View File

@ -1,31 +1,26 @@
# ajouter shared_path, modifier liens symboliques & mkdir
# changer unicorn_init_d
# changer unicorn.rb
# changer nginx.conf
set :application, 'sideplace_app'
set :domain, 'sideplace.bally.me'
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.1.2'
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
@ -38,13 +33,10 @@ role :db, domain, :primary => true
set :scm, :git
set :repository, "#{scm_user}@#{scm_host}:root/#{application}.git"
set :repository, "#{scm_user}@#{scm_host}:nicolas/#{application}.git"
set :branch, "master"
set :shared_path, "/media/bigone/shareds/#{application}"
default_run_options[:pty] = true
@ -57,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)
@ -68,80 +60,75 @@ namespace :deploy do
# end
# end
# end
desc "Symlink shared config files"
task :symlink_config_files do
run "ln -s #{shared_path}/private #{current_path}/private_medias"
run "ln -s #{shared_path}/pdf #{current_path}/pdf"
run "ln -s #{shared_path}/public #{current_path}/public/public_medias"
run "ln -s #{shared_path}/production.sqlite3 #{current_path}/db/production.sqlite3"
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 "
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 "sudo systemctl enable quartz_app@#{application}"
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
task :db_create do
run "cd #{deploy_to}current && bundle exec rake db:create RAILS_ENV=#{rails_env}"
end
task :seeds do
run "cd #{deploy_to}current && bundle exec rake db:seed RAILS_ENV=#{rails_env}"
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"
run "mkdir #{shared_path}/private"
run "mkdir #{shared_path}/public"
run "mkdir #{deploy_to}shared/storage"
run "mkdir #{deploy_to}shared/storage/private"
run "mkdir #{deploy_to}shared/storage/public"
run "mkdir #{deploy_to}shared/tmp"
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"
@ -154,4 +141,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.1.2
ENV=production
APP_ROOT=/srv/www/web/sideplace_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,31 @@
upstream sideplace_app_unicorn {
server unix:/home/web/sideplace_app/unicorn.sock fail_timeout=0;
server unix:/srv/www/web/sideplace_app/shared/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80;
listen [::]:80;
server_name sideplace.quartz.xyz sideplace.com ;
root /srv/www/web/sideplace_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://sideplace_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 blog.sideplace.com affiliation-sideplace.com affiliation.sideplace.com;
root /home/web/sideplace_app/current/public;
root /srv/www/web/sideplace_app/current/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
@ -21,16 +41,16 @@ server {
keepalive_timeout 10;
}
server {
listen 80;
server_name sideplace.com www.sideplace.com sideplace.bally.me tmp.sideplace.com ;
rewrite ^(.*) https://sideplace.com$1 permanent;
}
#server {
# listen 80;
#server_name sideplace.com www.sideplace.com sideplace.bally.me tmp.sideplace.com ;
#rewrite ^(.*) https://sideplace.com$1 permanent;
#}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name sideplace.com blog.sideplace.com affiliation-sideplace.com affiliation.sideplace.com;
root /home/web/sideplace_app/current/public;

View File

@ -1,10 +1,10 @@
@rails_app = "sideplace_app"
working_directory "/home/web/#{@rails_app}/current"
pid "/home/web/#{@rails_app}/unicorn.pid"
stderr_path "/media/bigone/shareds/#{@rails_app}/unicorn.log"
stdout_path "/media/bigone/shareds/#{@rails_app}/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}/unicorn.sock"
listen "/srv/www/web/#{@rails_app}/shared/tmp/unicorn.sock"
worker_processes 2
timeout 2000
timeout 600