Commit dc7a3a6d by Tran Hoang Viet

Initialize library to deploy

parent f09632a0
...@@ -11,4 +11,5 @@ ...@@ -11,4 +11,5 @@
/log/* /log/*
!/log/.keep !/log/.keep
/tmp /tmp
/public/uploads/ /public/uploads/
\ No newline at end of file /config/database.yml
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano3/unicorn'
# Load custom tasks from `lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
\ No newline at end of file
source 'https://rubygems.org' source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
...@@ -80,4 +80,11 @@ gem 'kaminari', '~> 0.16.3' ...@@ -80,4 +80,11 @@ gem 'kaminari', '~> 0.16.3'
gem 'rsolr', '~> 1.0.12' gem 'rsolr', '~> 1.0.12'
gem 'seed_migration', '~> 1.0.5' gem 'seed_migration', '~> 1.0.5'
\ No newline at end of file gem 'rails_12factor', '~> 0.0.3'
group :development do
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano3-unicorn'
end
\ No newline at end of file
GEM GEM
remote: https://rubygems.org/ remote: http://rubygems.org/
specs: specs:
actionmailer (4.2.3) actionmailer (4.2.3)
actionpack (= 4.2.3) actionpack (= 4.2.3)
...@@ -44,6 +44,21 @@ GEM ...@@ -44,6 +44,21 @@ GEM
builder (3.2.2) builder (3.2.2)
byebug (5.0.0) byebug (5.0.0)
columnize (= 0.9.0) columnize (= 0.9.0)
capistrano (3.4.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.1.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano3-unicorn (0.2.1)
capistrano (~> 3.1, >= 3.1.0)
carrierwave (0.10.0) carrierwave (0.10.0)
activemodel (>= 3.2.0) activemodel (>= 3.2.0)
activesupport (>= 3.2.0) activesupport (>= 3.2.0)
...@@ -59,6 +74,7 @@ GEM ...@@ -59,6 +74,7 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.9.1.1) coffee-script-source (1.9.1.1)
colorize (0.7.7)
columnize (0.9.0) columnize (0.9.0)
connection_pool (2.2.0) connection_pool (2.2.0)
database_cleaner (1.4.1) database_cleaner (1.4.1)
...@@ -138,6 +154,9 @@ GEM ...@@ -138,6 +154,9 @@ GEM
multi_json (1.11.2) multi_json (1.11.2)
multi_xml (0.5.5) multi_xml (0.5.5)
mysql2 (0.3.18) mysql2 (0.3.18)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
nokogiri (1.6.6.2) nokogiri (1.6.6.2)
mini_portile (~> 0.6.0) mini_portile (~> 0.6.0)
orm_adapter (0.5.0) orm_adapter (0.5.0)
...@@ -171,6 +190,11 @@ GEM ...@@ -171,6 +190,11 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1) rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2) rails-html-sanitizer (1.0.2)
loofah (~> 2.0) loofah (~> 2.0)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.4)
rails_stdout_logging (0.0.3)
railties (4.2.3) railties (4.2.3)
actionpack (= 4.2.3) actionpack (= 4.2.3)
activesupport (= 4.2.3) activesupport (= 4.2.3)
...@@ -236,6 +260,10 @@ GEM ...@@ -236,6 +260,10 @@ GEM
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0) sprockets (>= 2.8, < 4.0)
sshkit (1.7.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
subexec (0.2.3) subexec (0.2.3)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
...@@ -274,6 +302,9 @@ PLATFORMS ...@@ -274,6 +302,9 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
byebug byebug
capistrano-rails
capistrano-rvm
capistrano3-unicorn
carrierwave (~> 0.10.0) carrierwave (~> 0.10.0)
coffee-rails (~> 4.1.0) coffee-rails (~> 4.1.0)
database_cleaner (~> 1.4.1) database_cleaner (~> 1.4.1)
...@@ -293,6 +324,7 @@ DEPENDENCIES ...@@ -293,6 +324,7 @@ DEPENDENCIES
pry-rails (~> 0.3.4) pry-rails (~> 0.3.4)
quiet_assets quiet_assets
rails (= 4.2.3) rails (= 4.2.3)
rails_12factor (~> 0.0.3)
rsolr (~> 1.0.12) rsolr (~> 1.0.12)
rspec-rails (~> 3.3.2) rspec-rails (~> 3.3.2)
sass-rails (~> 5.0) sass-rails (~> 5.0)
......
# MySQL. Versions 5.0+ are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
#
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: 123456
#socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: venshop_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: venshop_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: venshop_vietth
password: 123456
...@@ -15,7 +15,7 @@ default: &default ...@@ -15,7 +15,7 @@ default: &default
pool: 5 pool: 5
username: root username: root
password: 123456 password: 123456
socket: /var/run/mysqld/mysqld.sock #socket: /var/run/mysqld/mysqld.sock
development: development:
<<: *default <<: *default
...@@ -49,6 +49,5 @@ test: ...@@ -49,6 +49,5 @@ test:
# #
production: production:
<<: *default <<: *default
database: venshop_production database: venshop_vietth
username: venShop
password: <%= ENV['VENSHOP_DATABASE_PASSWORD'] %> password: <%= ENV['VENSHOP_DATABASE_PASSWORD'] %>
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'vietth'
set :repo_url, 'git@gitlab.zigexn.vn:vietth/VietTH-VenShop.git'
# set :branch, 'master'
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :use_sudo, false
set :bundle_binstubs, nil
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
task :restart do
# invoke 'unicorn:reload'
on roles(:app) do
within current_path do
with rails_env: fetch(:rails_env) do
execute :bundle, "exec unicorn -c /web/training/vietth/current/config/unicorn/production.rb -D"
end
end
end
end
end
\ No newline at end of file
set :port, 22
set :user, 'ventura'
set :deploy_via, :remote_cache
set :use_sudo, false
server '192.168.1.204',
roles: [:web, :app, :db],
port: fetch(:port),
user: fetch(:user),
primary: true
set :deploy_to, "/web/training/#{fetch(:application)}"
set :ssh_options, {
forward_agent: true,
auth_methods: %w(publickey),
user: 'ventura',
}
set :rails_env, :production
set :conditionally_migrate, true
\ No newline at end of file
# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}
# role-based syntax
# ==================
# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.
# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db, %w{deploy@example.com}
# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
...@@ -6,7 +6,7 @@ Devise.setup do |config| ...@@ -6,7 +6,7 @@ Devise.setup do |config|
# confirmation, reset password and unlock tokens in the database. # confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key` # Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`
# by default. You can change it below and use your own secret key. # by default. You can change it below and use your own secret key.
# config.secret_key = '0b9650b3a0239f3503be39e87a6d183934750b8d58d8ba86657170d33ee1be55432c0047d32342832211f9788e0cdbb86fb4dd5066b4e1c8a508a91284b2f1bd' config.secret_key = '0b9650b3a0239f3503be39e87a6d183934750b8d58d8ba86657170d33ee1be55432c0047d32342832211f9788e0cdbb86fb4dd5066b4e1c8a508a91284b2f1bd'
# ==> Mailer Configuration # ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer, # Configure the e-mail address which will be shown in Devise::Mailer,
......
root = "/web/training/vietth/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/unicorn.vietth.sock"
worker_processes 2
timeout 30
preload_app true
###########################################
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
# Force the bundler gemfile environment variable to
# reference the capistrano "current" symlink
before_exec do |_|
ENV['BUNDLE_GEMFILE'] = File.join(root, 'Gemfile')
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment