์ด ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค(mina 0.3์์ ์ ๊ทธ๋ ์ด๋๋จ).
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
set :shared_dirs, %w(log public/uploads node_modules)
set :current_path, 'current'
set :term_mode, nil
task :environment do
invoke :'rbenv:load'
end
task setup: :environment do
command %[mkdir -p "#{fetch(:shared_path)}/log"]
command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/log"]
command %[mkdir -p "#{fetch(:shared_path)}/public/uploads"]
command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/public/uploads"]
command %[mkdir -p "#{fetch(:shared_path)}/node_modules"]
command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/node_modules"]
end
desc 'Deploys the current version to the server.'
task deploy: :environment do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'npm_install'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
on :launch do
command "mkdir -p #{fetch(:current_path)}/tmp/"
command "touch #{fetch(:current_path)}/tmp/restart.txt"
end
end
end
task :restart do
command "touch #{fetch(:current_path)}/tmp/restart.txt"
end
task :logs do
command 'echo "Contents of the log file are as follows:"'
command "tail -f #{fetch(:current_path)}/log/#{fetch(:rails_env)}.log"
end
task :npm_install do
command 'npm install --production'
end
๋ฌธ์ ๋ - bundle install
๊ฐ ๋ฐฐํฌ๊ฐ ์๋ฃ๋ ๋๋ง๋ค ์ฒ์๋ถํฐ ๋ชจ๋ gem์ ๋ค์ด๋ก๋ํ๋ค๋ ๊ฒ์
๋๋ค. ๋ฒ์ 0.3์์ ์ ์๋ํ์ต๋๋ค.
๋ด๊ฐ ๋ญ ์๋ชปํ๊ณ ์๋์ง ์ด๋ค ์๊ฐ?
์ข์, ๋ฌด์์ด ๋ฌธ์ ์ธ์ง ์์๋๋ค. ๋ฒ์ 1์์๋ ์ ์ฒด ํ ์ด๋ธ์ ๋ง๋๋ ๋์ shared_dirs์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ๊ทธ๋์ ๋ด๊ฐ ํ :
set :shared_dirs, fetch(:shared_dirs, []).push('log').push('public/uploads').push('node_modules')
๊ทธ๋ฆฌ๊ณ ์ง๊ธ ์๋ํฉ๋๋ค
๊ฐ์ฌ ํด์! ๋๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์๋ค!
๋ซํ ์ค๋ ๋์ ๊ณ ์ ํ๋ ค๋ ๊ฒ์ ์๋์ง๋ง ๋ค์๊ณผ ๊ฐ์ด ํ ์๋ ์์ต๋๋ค.
shared_dires = %w{log public/uploads node_modules}
set :shared_dirs, fetch(:shared_dirs, []).push(*shared_dirs)
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ข์, ๋ฌด์์ด ๋ฌธ์ ์ธ์ง ์์๋๋ค. ๋ฒ์ 1์์๋ ์ ์ฒด ํ ์ด๋ธ์ ๋ง๋๋ ๋์ shared_dirs์ ์ถ๊ฐํด์ผ ํฉ๋๋ค. ๊ทธ๋์ ๋ด๊ฐ ํ :
set :shared_dirs, fetch(:shared_dirs, []).push('log').push('public/uploads').push('node_modules')
๊ทธ๋ฆฌ๊ณ ์ง๊ธ ์๋ํฉ๋๋ค