-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
78 lines (60 loc) · 1.45 KB
/
Rakefile
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
71
72
73
74
75
76
77
78
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "test/*_test.rb"
end
## Manage app startup/shutdown
desc "Run app in foreground"
task :run do
sh "bundle exec thin start"
end
desc "Start app server"
task :start do
sh "bundle exec thin start -C config/thin.yml"
end
desc "Stop app server"
task :stop do
sh "bundle exec thin stop -C config/thin.yml"
end
desc 'Restart app server'
task :restart do
sh "bundle exec thin stop -C config/thin.yml; bundle exec thin start -C config/thin.yml"
end
desc "Start app IRB session"
task :shell do
sh "bundle exec racksh"
end
## Manage app deployment
desc "Run full deployment"
task :deploy do
remote "git fetch && git reset --hard origin/master && bundle install --deployment && rake restart"
end
namespace :deploy do
desc "Setup app for deployment"
task :setup do
remote "cd .. && git clone [email protected]:MYGITUSER/MYGITPROJECT.git"
end
desc "Deploy app to server"
task :update do
remote "git fetch && git reset --hard origin/master"
end
desc "Install ruby gems"
task :bundle do
remote "bundle install --deployment"
end
desc "Restart server"
task :restart do
remote "rake restart"
end
desc "Stop server"
task :stop do
remote "rake stop"
end
desc "Start server"
task :start do
remote "rake start"
end
def remote(command)
hosts = %w{ MYAPPSERVER1 MYAPPSERVER2 }
sh "relay -c 'cd /var/www/MYAPP && #{command}' #{hosts.join(' ')}"
end
end