Last active
November 5, 2023 22:57
-
-
Save dthtien/6d3dce146530a7b4d0bc7cc3c6b55cc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config valid for current version and patch releases of Capistrano | |
lock "~> 3.11.0" | |
set :message, "Deploy voucher trader api app" | |
set :application, "voucher_trader_api" | |
set :repo_url, "[email protected]:dthtien/voucher_trader_api.git " | |
set :deploy_user, 'deploy' | |
# Default branch is :master | |
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp | |
# Default deploy_to directory is /var/www/my_app_name | |
set :deploy_to, "/home/#{fetch :deploy_user}/#{fetch :application}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream app { | |
server unix:/home/deploy/voucher_trader_api/shared/sockets/puma.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default; | |
root /home/deploy/voucher_trader_api/current/public; | |
try_files $uri/index.html $uri @app; | |
location @app { | |
proxy_pass http://app; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_redirect off; | |
proxy_set_header Host $http_host; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workers 1 | |
threads 1, 6 | |
# Specifies the `port` that Puma will listen on to receive requests; default is 3000. | |
app_dir = '/home/deploy/voucher_trader_api' | |
current_dir = "#{app_dir}/current" | |
shared_dir = "#{app_dir}/shared" | |
# Specifies the `environment` that Puma will run in. | |
rails_env = ENV['RAILS_ENV'] || 'production' | |
environment rails_env | |
#Set up socket location | |
bind "unix://#{shared_dir}/sockets/puma.sock" | |
# Logging | |
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true | |
# setup master PID and state location | |
pidfile "#{shared_dir}/pids/puma.pid" | |
state_path "#{shared_dir}/pids/puma.state" | |
activate_control_app | |
on_worker_boot do | |
require "active_record" | |
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished | |
ActiveRecord::Base.establish_connection(YAML.load_file("#{current_dir}/config/database.yml")[rails_env]) | |
end | |
~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#VPS | |
sudo adduser deploy | |
sudo vim /etc/sudoers | |
%deploy ALL=(ALL) NOPASSWD: ALL | |
sudo su - deploy | |
mkdir .ssh | |
sudo chmod 700 .ssh | |
vim ~/.ssh/authorized_keys | |
sudo chmod 600 ~/.ssh/authorized_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment