Commit f97d462f authored by nazarf's avatar nazarf

add deploy

parent 0875df37
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
# Load the SCM plugin appropriate to your project:
#
# require "capistrano/scm/hg"
# install_plugin Capistrano::SCM::Hg
# or
# require "capistrano/scm/svn"
# install_plugin Capistrano::SCM::Svn
# or
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails
# https://github.com/capistrano/passenger
#
# require "capistrano/rvm"
# require "capistrano/rbenv"
# require "capistrano/chruby"
# require "capistrano/bundler"
# require "capistrano/rails/assets"
# require "capistrano/rails/migrations"
# require "capistrano/passenger"
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
......@@ -22,7 +22,6 @@ gem 'bootstrap', '~> 4.4.1'
gem 'font-awesome-sass', '~> 5.12.0'
gem 'bootstrap-will_paginate'
gem 'bcrypt', '~> 3.1.7' # Use ActiveModel has_secure_password
gem 'devise'
......@@ -35,14 +34,12 @@ gem 'curb'
gem 'telegram-bot-ruby'
gem 'whenever', require: false
group :development do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw], group: :development
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem "capistrano", "~> 3.16", require: false
end
group :development, :test do
......
# config valid only for current version of Capistrano
# lock '3.10.2'
# DEPLOY
set :application, 'marketGrab'
# set :deploy_to, '/var/www/amaox' # Default deploy_to directory is /var/www/my_app_name
set :repo_url, 'http://deploy:zpxocivu73@git.sp-service.com.ua/nazarf/marketparser.git'
# set :format, :pretty # Default value for :format is :pretty
# set :log_level, :debug # Default value for :log_level is :debug
# set :pty, true # Default value for :pty is false
# set :linked_files, fetch(:linked_files, []).push('config/vacancies.yml') # Default is []
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'public/uploads', 'files') # Default is []
# set :default_env, { path: "/opt/ruby/bin:$PATH" } # Default value for default_env is {}
# set :keep_releases, 5 # Default value for keep_releases is 5
# RVM
# set :rvm_type, :user # Defaults to: :auto
set :rvm_ruby_version, '2.5.1' # Defaults to: 'default'
# set :rvm_custom_path, '~/.rvm' # only needed if not detected
# RAILS
set :rails_env, 'production' # If the environment differs from the stage name
# set :migration_role, 'migrator' # Defaults to 'db'
# set :conditionally_migrate, true # Defaults to false. If true, it's skip migration if files in db/migrate not modified
# set :assets_roles, [:web, :app] # Defaults to [:web]
# BUNDLER
# In order to the bundler install gems to default directory otherwise it will be create gems folder in project directory
set :bundle_path, -> {}
set :bundle_flags, '--system --quiet'
# WHENEVER
set :whenever_roles, -> { [:app] }
puts "Started deploy in #{fetch(:stage)} mode!"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app) do
execute "mkdir -p #{File.join(current_path, 'tmp')}; touch #{File.join(current_path, 'tmp', 'restart.txt')}"
end
end
desc 'Reload the database with seed data'
task :seed do
on roles(:app) do
within "#{current_path}" do
with rails_env: :production do
execute :rake, "db:seed"
end
end
end
end
desc 'Tail production log'
task :tail_log do
on roles(:app) do
trap('INT') { puts 'Interupted'; exit 0; }
execute "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
puts # for an extra line break before the host name
puts "#{channel[:host]}: #{data}"
break if stream == :err
end
end
end
desc 'Set area and cost for sale contracts'
task :set_area_and_cost_for_sale_contracts do
on roles(:app) do
within "#{current_path}" do
with rails_env: :production do
execute :rake, 'set_area_and_cost_for_sale_contracts'
end
end
end
end
after 'deploy:publishing', 'deploy:restart'
after :restart, :x_bin_rails do
on roles(:web), in: :groups, limit: 3, wait: 10 do
within release_path do
execute :chmod, "u+x bin/rails"
end
end
end
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
# 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/user_name/.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"
# }
server '192.168.4.72', user: 'deploy', roles: %w{app db web}
set :branch, ENV['BRANCH'] if ENV['BRANCH']
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