-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
97 lines (77 loc) · 1.81 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require 'irb'
load File.expand_path('benchmark/benchmark.rake', __dir__)
INSTANCES = {
falcon: 'falcon',
passenger: 'passenger',
passenger_standalone: 'passenger-standalone',
puma: 'puma',
unicorn: 'unicorn',
}
BASE = %w{base base-devel postgresql git ruby ruby-rake ruby-bundler}
PACKAGES = {
passenger: %w{nginx nginx-mod-passenger},
passenger_standalone: %w{passenger}
}
task :clean do
INSTANCES.each do |name, path|
if task = task.application.lookup(:"#{name}:stop")
task.invoke
end
FileUtils::Dry.rm_rf(path)
end
end
INSTANCES.each do |name, path|
namespace name do
task :root do
FileUtils.mkdir_p path
end
task :base => :root do
sh "sudo", "pacstrap", "-c", path, *BASE, *PACKAGES[name]
end
task :setup => :base do
sh "sudo cp -r setup/base/* #{path}/"
sh "sudo cp -r setup/#{path}/* #{path}/"
sh "sudo arch-chroot #{path} rake setup"
end
task :stop do
sh "sudo", "machinectl", "stop", path.to_s
sh "sudo", "tmux", "kill-session", "-t", name.to_s
rescue
# Ignore
end
task :start do
sh "sudo", "tmux", "new-session", "-d", "-s", name.to_s, "systemd-nspawn --network-veth --boot -D #{path}"
rescue
# Ignore
end
task :attach do
sh "sudo", "tmux", "attach", "-t", name.to_s
end
task :shell do
sh "sudo", "machinectl", "shell", path.to_s
end
task :test do
sh "curl", "--output", "/dev/null", "http://#{path}/small"
end
end
end
task :setup do
INSTANCES.each do |name, path|
task.application[:"#{name}:setup"].invoke
end
end
task :stop do
INSTANCES.each do |name, path|
task.application[:"#{name}:stop"].invoke
end
end
task :start do
INSTANCES.each do |name, path|
task.application[:"#{name}:start"].invoke
end
end
task :test do
INSTANCES.each do |name, path|
task.application[:"#{name}:test"].invoke
end
end