cap deployment setup
This commit is contained in:
9
Capfile
9
Capfile
@@ -22,10 +22,15 @@ require "capistrano/bundler"
|
||||
require "capistrano/rails"
|
||||
require "capistrano/rails/assets"
|
||||
require "capistrano/rails/migrations"
|
||||
# require "capistrano/passenger"
|
||||
require "capistrano/scm/git"
|
||||
install_plugin Capistrano::SCM::Git
|
||||
|
||||
require 'capistrano/puma'
|
||||
install_plugin Capistrano::Puma, load_hooks: false # Default puma tasks
|
||||
install_plugin Capistrano::Puma::Monit # if you need the monit tasks
|
||||
install_plugin Capistrano::Puma::Jungle # if you need the jungle tasks
|
||||
|
||||
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
|
||||
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
|
||||
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
|
||||
Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }
|
||||
|
||||
|
||||
1
Gemfile
1
Gemfile
@@ -113,6 +113,7 @@ group :development do
|
||||
gem 'capistrano-bundler'
|
||||
gem 'capistrano-rails'
|
||||
gem 'capistrano-rbenv', github: "capistrano/rbenv"
|
||||
gem 'capistrano3-puma'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
||||
@@ -73,6 +73,10 @@ GEM
|
||||
capistrano-rails (1.3.1)
|
||||
capistrano (~> 3.1)
|
||||
capistrano-bundler (~> 1.1)
|
||||
capistrano3-puma (3.1.1)
|
||||
capistrano (~> 3.7)
|
||||
capistrano-bundler
|
||||
puma (~> 3.4)
|
||||
carrierwave (1.2.1)
|
||||
activemodel (>= 4.0.0)
|
||||
activesupport (>= 4.0.0)
|
||||
@@ -317,6 +321,7 @@ DEPENDENCIES
|
||||
capistrano-bundler
|
||||
capistrano-rails
|
||||
capistrano-rbenv!
|
||||
capistrano3-puma
|
||||
carrierwave (~> 1.0)
|
||||
chartkick
|
||||
coffee-rails (~> 4.2)
|
||||
@@ -368,4 +373,4 @@ RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.1
|
||||
2.0.2
|
||||
|
||||
@@ -18,13 +18,13 @@ class Customer < ApplicationRecord
|
||||
paginates_per 50
|
||||
|
||||
def self.get_member_account(customer)
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
|
||||
membership = MembershipSetting.active.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.active.find_by_membership_type("get_all_member_account")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
# urltest =self.url_exist?(url)
|
||||
|
||||
if !membership.nil? && !memberaction.nil?
|
||||
begin
|
||||
response = HTTParty.get(url, :body => {
|
||||
membership_id: customer.membership_id,
|
||||
@@ -49,6 +49,9 @@ class Customer < ApplicationRecord
|
||||
rescue SocketError
|
||||
response = { status: false, message: "Can't connect server"}
|
||||
end
|
||||
else
|
||||
response = {status: false, message: "There is no membership setting."}
|
||||
end
|
||||
Rails.logger.debug "--------Get Member Account response -------"
|
||||
Rails.logger.debug response.to_json
|
||||
return response;
|
||||
|
||||
@@ -721,7 +721,6 @@ $(document).ready(function(){
|
||||
var sale_id = $('#sale_id').text();
|
||||
window.location.replace('/origami/sale/'+sale_id+'/cashier/payment');
|
||||
}
|
||||
|
||||
/* replace url type*/
|
||||
/* start check first bill or not*/
|
||||
var member_id = $('#membership_id').text();
|
||||
@@ -1125,6 +1124,8 @@ $(document).ready(function(){
|
||||
<% else %>
|
||||
$('#balance').text(parseFloat(result));
|
||||
<% end %>
|
||||
|
||||
show_hide_btn($('#balance').text());
|
||||
}
|
||||
|
||||
function customer_display_view(data,status) {
|
||||
@@ -1831,4 +1832,15 @@ $(document).ready(function(){
|
||||
}
|
||||
},100);
|
||||
});
|
||||
|
||||
function show_hide_btn(balance) {
|
||||
// show discount when balance is greater than 0
|
||||
// if(parseFloat(balance) > 0){
|
||||
// $("#discount").show();
|
||||
// $("#edit").show();
|
||||
// }else{
|
||||
// $("#discount").hide();
|
||||
// $("#edit").hide();
|
||||
// }
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,20 +1,105 @@
|
||||
lock "3.10.1"
|
||||
# config valid only for current version of Capistrano
|
||||
lock '3.11.2'
|
||||
|
||||
set :application, "zsai"
|
||||
set :repo_url, 'git@bitbucket.org:code2lab/sxrestaurant.git'
|
||||
set :application, 'SmartsalesSX'
|
||||
|
||||
set :deploy_user, 'deploy'
|
||||
set :deploy_to, '/home/deploy/apps/SmartsalesSX'
|
||||
|
||||
set :rbenv_type, :global
|
||||
# setup repo details
|
||||
#set :scm, :git
|
||||
set :repo_url, 'git@gitlab.com:code2lab/SXRestaurant.git'
|
||||
|
||||
# setup rbenv.
|
||||
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
|
||||
|
||||
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
|
||||
|
||||
# how many old releases do we want to keep, not much
|
||||
set :keep_releases, 5
|
||||
|
||||
set :linked_files, %w{config/database.yml config/secrets.yml config/puma.rb config/sidekiq.yml config/shops.json config/cable.yml}
|
||||
# files we want symlinking to specific entries in shared
|
||||
set :linked_files, %w{config/database.yml config/secrets.yml}
|
||||
|
||||
set :linked_dirs, %w{bin log tmp/puma tmp/pids tmp/cache tmp/sockets vendor/bundle public/system pids sockets}
|
||||
# dirs we want symlinking to shared
|
||||
set :linked_dirs, %w{log tmp/pids tmp/puma tmp/cache tmp/sockets vendor/bundle public/system}
|
||||
|
||||
# what specs should be run before deployment is allowed to
|
||||
# continue, see lib/capistrano/tasks/run_tests.cap
|
||||
set :tests, []
|
||||
set :pty, true
|
||||
|
||||
set :puma_jungle_conf, '/etc/puma.conf'
|
||||
set :puma_run_path, '/usr/local/bin/run-puma'
|
||||
set :puma_bind, %w(tcp://0.0.0.0:9393)
|
||||
|
||||
#set :enable_ssl, true
|
||||
|
||||
# which config files should be copied by deploy:setup_config
|
||||
# see documentation in lib/capistrano/tasks/setup_config.cap
|
||||
# for details of operations
|
||||
set(:config_files, %w(
|
||||
database.yml
|
||||
log_rotation
|
||||
monit.conf
|
||||
sidekiq_init.sh
|
||||
sidekiq.yml
|
||||
))
|
||||
|
||||
# which config files should be made executable after copying
|
||||
# by deploy:setup_config
|
||||
set(:executable_config_files, %w(
|
||||
sidekiq_init.sh
|
||||
))
|
||||
|
||||
# files which need to be symlinked to other parts of the
|
||||
# filesystem. For example nginx virtualhosts, log rotation
|
||||
# init scripts etc. The full_app_name variable isn't
|
||||
# available at this point so we use a custom template {{}}
|
||||
# tag and then add it at run time.
|
||||
set(:symlinks, [
|
||||
{
|
||||
source: "sidekiq_init.sh",
|
||||
link: "/etc/init.d/sidekiq_{{full_app_name}}"
|
||||
},
|
||||
{
|
||||
source: "log_rotation",
|
||||
link: "/etc/logrotate.d/{{full_app_name}}"
|
||||
},
|
||||
{
|
||||
source: "monit",
|
||||
link: "/etc/monit/conf.d/{{full_app_name}}.conf"
|
||||
}
|
||||
])
|
||||
|
||||
# this:
|
||||
# http://www.capistranorb.com/documentation/getting-started/flow/
|
||||
# is worth reading for a quick overview of what tasks are called
|
||||
# and when for `cap stage deploy`
|
||||
|
||||
namespace :deploy do
|
||||
# make sure we're deploying what we think we're deploying
|
||||
before :deploy, "deploy:check_revision"
|
||||
# only allow a deploy with passing tests to deployed
|
||||
before :deploy, "deploy:run_tests"
|
||||
# compile assets locally then rsync
|
||||
after 'deploy:symlink:shared', 'deploy:compile_assets_locally'
|
||||
|
||||
after :finishing, 'deploy:cleanup'
|
||||
|
||||
#nginx will be install in the Load Balancer - No need to deploy there
|
||||
# remove the default nginx configuration as it will tend
|
||||
# to conflict with our configs.
|
||||
#before 'deploy:setup_config', 'nginx:remove_default_vhost'
|
||||
|
||||
# reload nginx to it will pick up any modified vhosts from
|
||||
# setup_config
|
||||
#after 'deploy:setup_config', 'nginx:reload'
|
||||
|
||||
# Restart monit so it will pick up any monit configurations
|
||||
# we've added
|
||||
#after 'deploy:setup_config', 'monit:restart'
|
||||
|
||||
# As of Capistrano 3.1, the `deploy:restart` task is not called
|
||||
# automatically.
|
||||
after 'finishing', 'puma:jungle:restart'
|
||||
end
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
set :stage, :production
|
||||
set :server_name, "svr.sxrestaurant.host"
|
||||
set :server_name, "a.c2l.shop"
|
||||
set :branch, "r-1902001-01"
|
||||
|
||||
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
||||
server '192.168.1.27', user: 'deploy', roles: %w{web app db}, primary: true
|
||||
server '167.71.194.57', user: 'deploy', roles: %w{web app db}, primary: true
|
||||
|
||||
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
|
||||
set :rbenv_ruby, '2.4.1'
|
||||
set :rbenv_ruby, '2.6.5'
|
||||
set :rails_env, :production
|
||||
|
||||
@@ -3,4 +3,6 @@ if File.exist?("config/license.yml")
|
||||
config.fetch(Rails.env, {}).each do |key, value|
|
||||
ENV[key.upcase] = value.to_s
|
||||
end
|
||||
else
|
||||
ENV["SERVER_MODE"] = "cloud"
|
||||
end
|
||||
Reference in New Issue
Block a user