/
deploy.rb
70 lines (56 loc) · 1.68 KB
/
deploy.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require 'mina/bundler'
require 'mina/git'
require 'mina/rbenv'
require './config/settings.rb'
set :domain, Configuration::SERVER['host']
set :deploy_to, Configuration::SERVER['deploy_to']
set :repository, Configuration::GIT['repository']
set :branch, Configuration::GIT['branch']
set :user, Configuration::SSH['user']
set :forward_agent, Configuration::SSH['forward_agent']
set :identity_file, Configuration::SSH['identity_file']
set :shared_paths, ['log', 'tmp']
task :environment do
invoke :'rbenv:load'
end
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/shared/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
queue! %[mkdir -p "#{deploy_to}/shared/tmp"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/tmp"]
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'
to :launch do
invoke :restart
end
end
end
desc "Restart the server."
task :restart => :environment do
in_directory "#{deploy_to}/#{current_path}" do
queue "bundle exec thin -R config.ru -p 4567 -d restart"
end
end
desc "Start the server."
task :start => :environment do
in_directory "#{deploy_to}/#{current_path}" do
queue "bundle exec thin -R config.ru -p 4567 -d start"
end
end
desc "Stop the server."
task :stop => :environment do
in_directory "#{deploy_to}/#{current_path}" do
queue "bundle exec thin -R config.ru -p 4567 -d stop"
end
end
desc "Report server process id"
task :info => :environment do
in_directory "#{deploy_to}/#{shared_path}" do
queue "print 'Server running with pid:' `cat tmp/pids/thin.pid`"
end
end