Commit 167428c9 by Tran Hoang Viet

VietTH: Deploy with mina

parent 65a31567
......@@ -98,4 +98,6 @@ gem 'font-awesome-rails', '~> 4.3.0.0'
gem 'meta-tags', '~> 2.0.0'
gem 'rolify', '~> 4.0.0'
\ No newline at end of file
gem 'rolify', '~> 4.0.0'
gem 'mina'
\ No newline at end of file
......@@ -159,6 +159,9 @@ GEM
actionpack (>= 3.0.0)
method_source (0.8.2)
mime-types (2.6.1)
mina (0.3.7)
open4 (~> 1.3.4)
rake
mini_magick (3.8.1)
subexec (~> 0.2.1)
mini_portile (0.6.2)
......@@ -171,6 +174,7 @@ GEM
net-ssh (2.9.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
open4 (1.3.4)
orm_adapter (0.5.0)
parser (2.2.2.6)
ast (>= 1.1, < 3.0)
......@@ -347,6 +351,7 @@ DEPENDENCIES
kaminari (~> 0.16.3)
letter_opener (~> 1.4.1)
meta-tags (~> 2.0.0)
mina
mini_magick (~> 3.8.1)
mysql2
pry-rails (~> 0.3.4)
......
......@@ -4,7 +4,7 @@ set :deploy_to, '/home/alicuche/Web/venshop'
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'git@gitlab.zigexn.vn:vietth/VietTH-VenShop.git'
set :branch, 'deploy_mina'
set :user, 'ventura'
set :user, 'alicuche'
set :forward_agent, true
set :port, '22'
set :shared_paths, ['config/database.yml', 'log', 'config/application.yml']
......
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Config
# ==============================================================================
set :term_mode, :system
set :rails_env, 'production'
set :domain, 'alicuche.koding.io'
set :port, 37894
set :deploy_to, "/home/alicuche/Web/venshop"
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'git@gitlab.zigexn.vn:vietth/VietTH-VenShop.git'
set :brach, 'deploy_mina'
set :user, 'apps'
set :shared_paths, ['config/database.yml', 'log', 'tmp', 'config/application.yml']
set :keep_releases, 5
# RVM
# ==============================================================================
set :rvm_path, '/home/alicuche/.rvm/scripts/rvm'
task :environment do
invoke 'rvm:use[2.1.5]'
end
# Setup task
# ==============================================================================
task :setup do
queue! %{
mkdir -p "#{deploy_to}/shared/tmp/pids"
}
end
# Deploy task
# ==============================================================================
desc "deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke 'git:clone'
invoke 'bundle:install'
invoke 'rails:db_migrate'
invoke 'rails:assets_precompile'
invoke 'deploy:link_shared_paths'
to :launch do
invoke :'unicorn:restart'
end
end
end
# Unicorn
# ==============================================================================
namespace :unicorn do
set :unicorn_pid, "#{app_path}/tmp/pids/unicorn.pid"
set :start_unicorn, %{
cd #{app_path}
bundle exec unicorn -c #{app_path}/config/unicorn/#{rails_env}.rb -E #{rails_env} -D
}
# Start task
# ------------------------------------------------------------------------------
desc "Start unicorn"
task :start => :environment do
queue 'echo "-----> Start Unicorn"'
queue! start_unicorn
end
# Stop task
# ------------------------------------------------------------------------------
desc "Stop unicorn"
task :stop do
queue 'echo "-----> Stop Unicorn"'
queue! %{
test -s "#{unicorn_pid}" && kill -QUIT `cat "#{unicorn_pid}"` && echo "Stop Ok" && exit 0
echo >&2 "Not running"
}
end
# Restart task
# ------------------------------------------------------------------------------
desc "Restart unicorn using 'upgrade'"
task :restart => :environment do
invoke 'unicorn:stop'
invoke 'unicorn:start'
end
end
\ No newline at end of file
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Config
# ==============================================================================
set :term_mode, :system
set :rails_env, 'staging'
set :domain, 'alicuche.koding.io'
# set :port, 37894
set :deploy_to, "/home/alicuche/Web/venshop"
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'git@bitbucket.org:alicuche/venshop.git'
set :branch, 'deploy_mina'
set :user, 'alicuche'
set :shared_paths, ['config/database.yml', 'log', 'tmp', 'config/application.yml']
set :keep_releases, 5
# RVM
# ==============================================================================
set :rvm_path, '/home/alicuche/.rvm/scripts/rvm'
task :environment do
invoke 'rvm:use[2.1.5]'
end
# Setup task
# ==============================================================================
task :setup do
queue! %{
mkdir -p "#{deploy_to}/shared/tmp/pids"
}
queue! %{
mkdir -p "#{deploy_to}/log"
}
end
# Deploy task
# ==============================================================================
desc "deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke 'git:clone'
invoke 'bundle:install'
invoke 'rails:db_migrate'
invoke 'rails:assets_precompile'
invoke 'deploy:link_shared_paths'
to :launch do
invoke :'unicorn:restart'
end
end
end
# Unicorn
# ==============================================================================
namespace :unicorn do
set :unicorn_pid, "#{app_path}/tmp/pids/unicorn.pid"
set :start_unicorn, %{
cd #{app_path}
bundle exec unicorn -c #{app_path}/config/unicorn/#{rails_env}.rb -E #{rails_env} -D
}
# Start task
# ------------------------------------------------------------------------------
desc "Start unicorn"
task :start => :environment do
queue 'echo "-----> Start Unicorn"'
queue! start_unicorn
end
# Stop task
# ------------------------------------------------------------------------------
desc "Stop unicorn"
task :stop do
queue 'echo "-----> Stop Unicorn"'
queue! %{
test -s "#{unicorn_pid}" && kill -QUIT `cat "#{unicorn_pid}"` && echo "Stop Ok" && exit 0
echo >&2 "Not running"
}
end
# Restart task
# ------------------------------------------------------------------------------
desc "Restart unicorn using 'upgrade'"
task :restart => :environment do
invoke 'unicorn:stop'
invoke 'unicorn:start'
end
end
\ No newline at end of file
......@@ -3,8 +3,8 @@ working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
stderr_path "/web/training/vietth/log/unicorn.log"
stdout_path "/web/training/vietth/log/unicorn.log"
listen "/tmp/unicorn.vietth.sock"
......
......@@ -3,8 +3,8 @@ working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
stderr_path "#{root}/../log/unicorn.log"
stdout_path "#{root}/../log/unicorn.log"
listen "/tmp/unicorn.venshop.sock"
......
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/mina/staging.rb'
end
task :production do
exec 'mina deploy -f config/mina/production.rb'
end
end
\ No newline at end of file
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