harbr 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/harbr/version.rb +1 -1
- data/lib/harbr.rb +48 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bf43c388ba400dbb6f749a1e5849b4b19caaf54c172a598bbe3abb6b009d0f9
|
4
|
+
data.tar.gz: 77853307c0b34b99e4d610cf8d55a9f3cc944d819022ddbf1183ae326895fcc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d97ad5384477376bd00dedff98e59a2e0bb8ea2cfe2529609b65e576a533a1ff2ec0a3f530209637245218a0e26233fac47b1214124ae766eb5812265300a908
|
7
|
+
data.tar.gz: 5c3c1e3cf128de073a8278c09a7ee376f5181ccb3c00c88ce07240d49fd87a6b8706a02b40e3296684451bbf70a8b39f97f1a7dac734faa8f257ffcb8c122578
|
data/lib/harbr/version.rb
CHANGED
data/lib/harbr.rb
CHANGED
@@ -19,29 +19,17 @@ module Harbr
|
|
19
19
|
class Error < StandardError; end
|
20
20
|
|
21
21
|
class Container
|
22
|
+
|
23
|
+
queries do
|
24
|
+
def find_by_header(host_header)
|
25
|
+
all.find { |container| container.host_header.downcase == host_header.downcase }
|
26
|
+
end
|
27
|
+
end
|
22
28
|
class Job
|
23
29
|
include SuckerPunch::Job
|
24
30
|
|
25
31
|
def perform(manifest)
|
26
|
-
|
27
|
-
puts "Starting container: #{manifest.name}"
|
28
|
-
|
29
|
-
Dddr.configure do |config|
|
30
|
-
config.data_dir = Harbr::DEFAULT_DIRECTORY_DATA_DIR
|
31
|
-
end
|
32
|
-
|
33
|
-
pool = Harbr::Port::Pool.new
|
34
|
-
port = pool.get_port(manifest.host)
|
35
|
-
|
36
|
-
create_a_service(manifest.name, port.number)
|
37
|
-
|
38
|
-
|
39
|
-
sleep 5
|
40
|
-
system("sv restart #{manifest.name}")
|
41
|
-
sleep 5
|
42
|
-
system("sv status #{manifest.name}")
|
43
|
-
puts "Started container: #{manifest.name}"
|
44
|
-
|
32
|
+
run_container(manifest)
|
45
33
|
end
|
46
34
|
|
47
35
|
|
@@ -56,7 +44,7 @@ module Harbr
|
|
56
44
|
#!/bin/sh
|
57
45
|
exec 2>&1
|
58
46
|
cd /var/harbr/#{container_name}/current
|
59
|
-
exec bundle exec puma -p #{port}
|
47
|
+
exec bundle install && bundle exec puma -p #{port}
|
60
48
|
SCRIPT
|
61
49
|
|
62
50
|
service_dir = "/etc/sv/harbr/#{container_name}"
|
@@ -68,12 +56,16 @@ module Harbr
|
|
68
56
|
end
|
69
57
|
|
70
58
|
def create_log_script(container_name)
|
59
|
+
|
71
60
|
log_dir = "/var/log/harbr/#{container_name}"
|
61
|
+
|
72
62
|
if File.directory?(log_dir)
|
73
63
|
puts "Directory already exists: #{log_dir}"
|
74
64
|
return
|
75
65
|
end
|
76
|
-
|
66
|
+
|
67
|
+
FileUtils.mkdir_p(log_dir)
|
68
|
+
|
77
69
|
script_template = <<~SCRIPT
|
78
70
|
#!/bin/sh
|
79
71
|
exec svlogd -tt #{log_dir}/
|
@@ -93,6 +85,41 @@ module Harbr
|
|
93
85
|
system("ln -s /etc/sv/harbr/#{container_name} /etc/service/#{container_name}") unless File.exist?("/etc/service/#{container_name}")
|
94
86
|
end
|
95
87
|
|
88
|
+
def run_container(manifest)
|
89
|
+
|
90
|
+
puts "Starting container: #{manifest.name}"
|
91
|
+
|
92
|
+
Dddr.configure do |config|
|
93
|
+
config.data_dir = Harbr::DEFAULT_DIRECTORY_DATA_DIR
|
94
|
+
end
|
95
|
+
|
96
|
+
pool = Harbr::Port::Pool.new
|
97
|
+
port = pool.get_port(manifest.host)
|
98
|
+
|
99
|
+
create_a_service(manifest.name, port.number)
|
100
|
+
|
101
|
+
|
102
|
+
sleep 5
|
103
|
+
system("sv restart #{manifest.name}")
|
104
|
+
sleep 5
|
105
|
+
system("sv status #{manifest.name}")
|
106
|
+
puts "Started container: #{manifest.name}"
|
107
|
+
|
108
|
+
|
109
|
+
container = Container.new
|
110
|
+
containers = Container::Repository.new
|
111
|
+
|
112
|
+
container.name = manifest.name
|
113
|
+
container.host_header = manifest.host
|
114
|
+
container.ip = manifest.ip
|
115
|
+
container.port = port.number
|
116
|
+
containers.add(container) unless containers.find_by_header(manifest.host)
|
117
|
+
|
118
|
+
puts "Started container: #{manifest.name}"
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
|
96
123
|
|
97
124
|
end
|
98
125
|
|