haconiwa 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/haconiwa/base.rb +2 -0
- data/lib/haconiwa/runners/linux.rb +24 -1
- data/lib/haconiwa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ddb95a0442d9007bda5a95609229cf0cef771a6
|
4
|
+
data.tar.gz: e56fd0275206c68766efc6e7c27a406aaf5db059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96efacf5d423f067a4fcf33bc624d32db67bb803c9b3123f93c546e4acf435bef82fc48fe58395a84a8eaec3556ac19651b09385102f8631b89e1bb71bb4b541
|
7
|
+
data.tar.gz: aeaadfc43ff779eb60d295e05a7f10589795f1e520ac453a426d31b4cc181ba00bc5d9d439fc110e29dafcfeb1995aa4eef4c5d1459768c0a026ee80923b4602
|
data/lib/haconiwa/base.rb
CHANGED
@@ -9,6 +9,7 @@ module Haconiwa
|
|
9
9
|
class Base
|
10
10
|
attr_accessor :name,
|
11
11
|
:init_command,
|
12
|
+
:container_pid_file,
|
12
13
|
:filesystem,
|
13
14
|
:cgroup,
|
14
15
|
:namespace,
|
@@ -24,6 +25,7 @@ module Haconiwa
|
|
24
25
|
@namespace = Namespace.new
|
25
26
|
@capabilities = Capabilities.new
|
26
27
|
@name = "haconiwa-#{Time.now.to_i}"
|
28
|
+
@container_pid_file = "/var/run/haconiwa-#{@name}.pid"
|
27
29
|
end
|
28
30
|
|
29
31
|
# aliases
|
@@ -45,8 +45,15 @@ module Haconiwa::Runners
|
|
45
45
|
end
|
46
46
|
}
|
47
47
|
|
48
|
+
sleep 0.1 # The magic
|
48
49
|
Haconiwa::SmallCgroup.register_at_exit(pid: container, name: base.name, dirs: base.cgroup.to_dirs)
|
49
|
-
|
50
|
+
real_container_pid = if base.namespace.use_pid_ns
|
51
|
+
find_by_ppid(container)
|
52
|
+
else
|
53
|
+
container
|
54
|
+
end
|
55
|
+
File.open(base.container_pid_file, "w") {|pid| pid.write real_container_pid }
|
56
|
+
puts "New container: PID = #{real_container_pid}"
|
50
57
|
|
51
58
|
res = Process.waitpid2 container
|
52
59
|
if res[1].success?
|
@@ -54,6 +61,22 @@ module Haconiwa::Runners
|
|
54
61
|
else
|
55
62
|
puts "Container exited with status code <#{res[1].to_i}>."
|
56
63
|
end
|
64
|
+
|
65
|
+
at_exit { FileUtils.rm_f base.container_pid_file }
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def self.find_by_ppid(ppid)
|
70
|
+
s = Dir.glob('/proc/*/stat')
|
71
|
+
.find {|stat|
|
72
|
+
next unless stat =~ /\d/
|
73
|
+
File.read(stat).split[3].to_i == ppid
|
74
|
+
}
|
75
|
+
if s
|
76
|
+
s.scan(/\d+/).first.to_i
|
77
|
+
else
|
78
|
+
raise("Process that has ppid #{ppid} not found. Somthing is wrong.")
|
79
|
+
end
|
57
80
|
end
|
58
81
|
end
|
59
82
|
end
|
data/lib/haconiwa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haconiwa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uchio KONDO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|