-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ddd0f8
commit 7ed11a5
Showing
7 changed files
with
234 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
require 'mina/multistage' | ||
require 'mina/bundler' | ||
require 'mina/rails' | ||
require 'mina/git' | ||
# require 'mina/rbenv' # for rbenv support. (https://rbenv.org) | ||
require 'mina/rvm' # for rvm support. (https://rvm.io) | ||
require 'mina/puma' | ||
|
||
# Basic settings: | ||
# domain - The hostname to SSH to. | ||
# deploy_to - Path to deploy into. | ||
# repository - Git repo to clone from. (needed by mina/git) | ||
# branch - Branch name to deploy. (needed by mina/git) | ||
|
||
set :application_name, 'ReBirth' | ||
set :domain, '47.97.171.140' | ||
set :deploy_to, '/home/deploy/ReBirth' | ||
set :repository, 'https://github.com/cryptape/ReBirth.git' | ||
set :branch, 'develop' | ||
set :rails_env, 'production' | ||
set :user, 'deploy' | ||
|
||
# Optional settings: | ||
# set :user, 'foobar' # Username in the server to SSH to. | ||
# set :port, '30000' # SSH port number. | ||
# set :forward_agent, true # SSH forward_agent. | ||
|
||
# Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step. | ||
# Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more | ||
# run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files` | ||
# set :shared_dirs, fetch(:shared_dirs, []).push('public/assets') | ||
# set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml') | ||
set :shared_dirs, fetch(:shared_dirs, []).push( | ||
'log', | ||
'tmp/pids', | ||
'tmp/sockets', | ||
'public/upload', | ||
'public/packs', | ||
'public/packs-test', | ||
'storage' | ||
) | ||
|
||
set :shared_files, fetch(:shared_files, []).push( | ||
'config/puma.rb', | ||
'config/master.key', | ||
'.env.local' | ||
) | ||
|
||
# This task is the environment that is loaded for all remote run commands, such as | ||
# `mina deploy` or `mina rake`. | ||
task :remote_environment do | ||
# If you're using rbenv, use this to load the rbenv environment. | ||
# Be sure to commit your .ruby-version or .rbenv-version to your repository. | ||
# invoke :'rbenv:load' | ||
|
||
# For those using RVM, use this to load an RVM version@gemset. | ||
# invoke :'rvm:use', 'ruby-1.9.3-p125@default' | ||
invoke :'rvm:use', 'ruby-2.5.1' | ||
end | ||
|
||
# Put any custom commands you need to run at setup | ||
# All paths in `shared_dirs` and `shared_paths` will be created on their own. | ||
task :setup do | ||
# command %{rbenv install 2.3.0 --skip-existing} | ||
command %[touch "#{fetch(:shared_path)}/config/puma.rb"] | ||
command %[touch "#{fetch(:shared_path)}/config/master.key"] | ||
command %[touch "#{fetch(:shared_path)}/.env.local"] | ||
comment color_str("Be sure to edit config files") | ||
end | ||
|
||
desc "Deploys the current version to the server." | ||
task :deploy do | ||
# uncomment this line to make sure you pushed your local branch to the remote origin | ||
# invoke :'git:ensure_pushed' | ||
deploy do | ||
# Put things that will set up an empty directory into a fully set-up | ||
# instance of your project. | ||
invoke :'git:clone' | ||
invoke :'deploy:link_shared_paths' | ||
invoke :'bundle:install' | ||
invoke :'rails:db_migrate' | ||
invoke :'rails:assets_precompile' | ||
invoke :'deploy:cleanup' | ||
|
||
on :launch do | ||
in_path(fetch(:current_path)) do | ||
invoke :'puma:phased_restart' | ||
end | ||
end | ||
end | ||
|
||
# you can use `run :local` to run tasks on local machine before of after the deploy scripts | ||
# run(:local){ say 'done' } | ||
end | ||
|
||
# For help in making your deploy script, see the Mina documentation: | ||
# | ||
# - https://github.com/mina-deploy/mina/tree/master/docs | ||
|
||
# color comment | ||
def color_str(str) | ||
"\x1b[0;33m#{str}\x1b[0m" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set :domain, '47.97.171.140' | ||
set :deploy_to, '/home/deploy/ReBirth' | ||
set :branch, 'develop' | ||
set :user, 'root' | ||
set :rvm_use_path, '/usr/share/rvm/scripts/rvm' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
upstream re-birth { | ||
server unix:///home/deploy/ReBirth/shared/tmp/sockets/puma.sock; | ||
} | ||
|
||
server { | ||
listen 80 default_server deferred; | ||
server_name example.com; | ||
|
||
root /home/deploy/ReBirth/current/public; | ||
access_log /home/deploy/ReBirth/current/log/nginx.access.log; | ||
error_log /home/deploy/ReBirth/current/log/nginx.error.log info; | ||
|
||
location ^~ /assets/ { | ||
gzip_static on; | ||
expires max; | ||
add_header Cache-Control public; | ||
} | ||
|
||
try_files $uri/index.html $uri @re-birth; | ||
location @re-birth { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
|
||
proxy_pass http://re-birth; | ||
} | ||
|
||
error_page 500 502 503 504 /500.html; | ||
client_max_body_size 10M; | ||
keepalive_timeout 10; | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Puma can serve each request in a thread from an internal thread pool. | ||
# The `threads` method setting takes two numbers: a minimum and maximum. | ||
# Any libraries that use thread pools should be configured to match | ||
# the maximum value specified for Puma. Default is set to 5 threads for minimum | ||
# and maximum; this matches the default thread size of Active Record. | ||
# | ||
# threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } | ||
# threads threads_count, threads_count | ||
|
||
# Specifies the `port` that Puma will listen on to receive requests; default is 3000. | ||
# | ||
# port ENV.fetch("PORT") { 3000 } | ||
|
||
# Specifies the `environment` that Puma will run in. | ||
# | ||
# environment ENV.fetch("RAILS_ENV") { "development" } | ||
|
||
# Specifies the number of `workers` to boot in clustered mode. | ||
# Workers are forked webserver processes. If using threads and workers together | ||
# the concurrency of the application would be max `threads` * `workers`. | ||
# Workers do not work on JRuby or Windows (both of which do not support | ||
# processes). | ||
# | ||
# workers ENV.fetch("WEB_CONCURRENCY") { 2 } | ||
|
||
# Use the `preload_app!` method when specifying a `workers` number. | ||
# This directive tells Puma to first boot the application and load code | ||
# before forking the application. This takes advantage of Copy On Write | ||
# process behavior so workers use less memory. If you use this option | ||
# you need to make sure to reconnect any threads in the `on_worker_boot` | ||
# block. | ||
# | ||
# preload_app! | ||
|
||
# If you are preloading your application and using Active Record, it's | ||
# recommended that you close any connections to the database before workers | ||
# are forked to prevent connection leakage. | ||
# | ||
# before_fork do | ||
# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) | ||
# end | ||
|
||
# The code in the `on_worker_boot` will be called if you are using | ||
# clustered mode by specifying a number of `workers`. After each worker | ||
# process is booted, this block will be run. If you are using the `preload_app!` | ||
# option, you will want to use this block to reconnect to any threads | ||
# or connections that may have been created at application boot, as Ruby | ||
# cannot share connections between processes. | ||
# | ||
# on_worker_boot do | ||
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) | ||
# end | ||
# | ||
|
||
# Allow puma to be restarted by `rails restart` command. | ||
# plugin :tmp_restart | ||
|
||
# sample for puma production env | ||
environment 'production' | ||
workers 2 | ||
threads 1, 6 | ||
|
||
app_name = "ReBirth" | ||
application_path = "/home/deploy/#{app_name}" | ||
directory "#{application_path}/current" | ||
|
||
pidfile "#{application_path}/shared/tmp/pids/puma.pid" | ||
state_path "#{application_path}/shared/tmp/sockets/puma.state" | ||
stdout_redirect "#{application_path}/shared/log/puma.stdout.log", "#{application_path}/shared/log/puma.stderr.log" | ||
bind "unix://#{application_path}/shared/tmp/sockets/puma.sock" | ||
activate_control_app "unix://#{application_path}/shared/tmp/sockets/pumactl.sock" | ||
|
||
daemonize true | ||
on_restart do | ||
puts 'On restart...' | ||
end | ||
preload_app! | ||
|