Capistranize
This commit is contained in:
parent
fd75f24ef6
commit
3ae76a9a57
4
Capfile
Executable file
4
Capfile
Executable file
@ -0,0 +1,4 @@
|
||||
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
|
||||
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
|
||||
|
||||
load 'config/deploy' # remove this line to skip loading any of the default tasks
|
4
Gemfile
4
Gemfile
@ -51,6 +51,10 @@ group :development do
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
|
||||
gem "capistrano", '2.15.5', group: :development
|
||||
gem "rvm-capistrano",'1.4.1', group: :development, require: false
|
||||
gem 'net-ssh', '~>2.7.0'
|
||||
end
|
||||
|
||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
|
19
Gemfile.lock
19
Gemfile.lock
@ -47,6 +47,12 @@ GEM
|
||||
sass (>= 3.3.4)
|
||||
builder (3.2.2)
|
||||
byebug (9.0.6)
|
||||
capistrano (2.15.5)
|
||||
highline
|
||||
net-scp (>= 1.0.0)
|
||||
net-sftp (>= 2.0.0)
|
||||
net-ssh (>= 2.0.14)
|
||||
net-ssh-gateway (>= 1.1.0)
|
||||
coffee-rails (4.2.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.2.x)
|
||||
@ -66,6 +72,7 @@ GEM
|
||||
gmaps4rails (2.1.2)
|
||||
haml (4.0.7)
|
||||
tilt
|
||||
highline (1.7.8)
|
||||
i18n (0.7.0)
|
||||
jbuilder (2.6.0)
|
||||
activesupport (>= 3.0.0, < 5.1)
|
||||
@ -88,6 +95,13 @@ GEM
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.9.1)
|
||||
multi_json (1.12.1)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-sftp (2.1.2)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (2.7.0)
|
||||
net-ssh-gateway (1.2.0)
|
||||
net-ssh (>= 2.6.5)
|
||||
nio4r (1.2.1)
|
||||
nokogiri (1.6.8.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
@ -123,6 +137,8 @@ GEM
|
||||
rb-fsevent (0.9.8)
|
||||
rb-inotify (0.9.7)
|
||||
ffi (>= 0.5.0)
|
||||
rvm-capistrano (1.4.1)
|
||||
capistrano (>= 2.0.0)
|
||||
sass (3.4.22)
|
||||
sass-rails (5.0.6)
|
||||
railties (>= 4.0.0, < 6)
|
||||
@ -169,6 +185,7 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
bootstrap-sass
|
||||
byebug
|
||||
capistrano (= 2.15.5)
|
||||
coffee-rails (~> 4.2)
|
||||
font-awesome-sass
|
||||
gmaps4rails
|
||||
@ -176,9 +193,11 @@ DEPENDENCIES
|
||||
jbuilder (~> 2.5)
|
||||
jquery-rails
|
||||
listen (~> 3.0.5)
|
||||
net-ssh (~> 2.7.0)
|
||||
puma (~> 3.0)
|
||||
rails (~> 5.0.0, >= 5.0.0.1)
|
||||
rails-assets-adminlte!
|
||||
rvm-capistrano (= 1.4.1)
|
||||
sass-rails (~> 5.0)
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
|
139
config/deploy.rb
Executable file
139
config/deploy.rb
Executable file
@ -0,0 +1,139 @@
|
||||
set :application, 'heylium-webapp'
|
||||
set :domain, 'app.heylium.io'
|
||||
|
||||
|
||||
|
||||
set :user, 'web'
|
||||
set :scm_user, "git"
|
||||
set :scm_host, "gitlab.quartz.xyz"
|
||||
|
||||
|
||||
|
||||
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 :use_sudo, false
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set :deploy_to, "/home/#{user}/#{application}/"
|
||||
set :deploy_via, :remote_cache
|
||||
|
||||
set :normalize_asset_timestamps, false
|
||||
|
||||
set :rails_env, "production"
|
||||
|
||||
role :app, domain
|
||||
role :web, domain
|
||||
role :db, domain, :primary => true
|
||||
|
||||
set :scm, :git
|
||||
|
||||
set :repository, "#{scm_user}@#{scm_host}:quartz/#{application}.git"
|
||||
|
||||
set :branch, "master"
|
||||
|
||||
default_run_options[:pty] = true
|
||||
|
||||
|
||||
require "rvm/capistrano"
|
||||
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)
|
||||
# if releases.length <= 1 || capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
|
||||
# run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
|
||||
# else
|
||||
# logger.info "Skipping asset pre-compilation because there were no asset changes"
|
||||
# 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/pdf #{current_path}/pdf"
|
||||
|
||||
|
||||
run "ln -s #{deploy_to}shared/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 "
|
||||
end
|
||||
|
||||
|
||||
|
||||
task :start do
|
||||
sudo "service #{application} start"
|
||||
end
|
||||
task :stop do
|
||||
run "service #{application} stop"
|
||||
end
|
||||
task :restart do
|
||||
sudo "service #{application} restart"
|
||||
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 :seeds 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"
|
||||
|
||||
#after "deploy:restart", "deploy:cleanup"
|
||||
|
||||
|
||||
before "deploy:restart", "deploy:symlink_config_files"
|
||||
|
||||
after "deploy", "deploy:cleanup"
|
27
config/nginx.conf
Executable file
27
config/nginx.conf
Executable file
@ -0,0 +1,27 @@
|
||||
upstream heylium-webapp_unicorn {
|
||||
server unix:/home/web/heylium-webapp/shared/unicorn.sock fail_timeout=0;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name negos.pro negos-pro.fr;
|
||||
root /home/web/heylium-webapp/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://app.heylium.io;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /500.html;
|
||||
client_max_body_size 4G;
|
||||
keepalive_timeout 10;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.negos-pro.fr www.negos.pro;
|
||||
rewrite ^(.*) http://negos.pro$1 permanent;
|
||||
}
|
10
config/unicorn.rb
Executable file
10
config/unicorn.rb
Executable file
@ -0,0 +1,10 @@
|
||||
@rails_app = "heylium-webapp"
|
||||
|
||||
working_directory "/home/web/#{@rails_app}/current"
|
||||
pid "/home/web/#{@rails_app}/shared/unicorn.pid"
|
||||
stderr_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/unicorn.sock"
|
||||
worker_processes 2
|
||||
timeout 30
|
64
config/unicorn_init_d
Executable file
64
config/unicorn_init_d
Executable file
@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
# Change these to match your app:
|
||||
APP_NAME=heylium-webapp
|
||||
APP_RUBY=2.1.2
|
||||
APP_ROOT="/home/web/heylium-webapp/current"
|
||||
PID="/home/web/heylium-webapp/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 $APP_RUBY"
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user