dapp 0.31.4 → 0.31.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dapp +64 -0
  3. data/lib/dapp/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92cbd45585608c2b3424c4db1e59b504beb8c1c90eced82f7b27a70eba995e3e
4
- data.tar.gz: 8e5c680b2a63f6cf7869f72c35efac3dc19f32bce3afddfe64f13f2f96614563
3
+ metadata.gz: 22cc8594fb78a6243a99c16f7f1a501b06ee1286b83c3524978500d5f35ee731
4
+ data.tar.gz: 4143dab497bcde117a36136f0bd780cb1f6a2d539c8d5ec431f1e7ca2a1aa831
5
5
  SHA512:
6
- metadata.gz: 0d307250a9a3cd29bc80528213685b55bed30cd4bd35c6925a78e8cd2187d3c4bebf00865d33acccf3240f834dd4eaf46baae408f0ba4c348a01aaf5cc167aa5
7
- data.tar.gz: fff8cc2b739262c7f14a7684d56824295d9b4e4e99597d80450b7a6382cf4aaf8b64dba3802979a5807e1ddbd69cf0bda38753ebf39ba5f95a85b2efc8d33938
6
+ metadata.gz: 86c27a5b641793dd2b1ac46d493b78474495f327056b490cd9c83353b12a55728dae98d5899ebab99dbd4d31727066f89d5f4e1ab7ac2d9aac0bd865bad7ffbb
7
+ data.tar.gz: 71f48d1aa6e29c7b7bf0465de3e460cd8ef828ea8e46a54edae24a7625ff99276953f9aaa0e94965c39b7762a13f78614157bb32db6a1d13b0aeb3f8675f95af
data/bin/dapp CHANGED
@@ -7,6 +7,70 @@ require 'dapp'
7
7
 
8
8
  Thread.abort_on_exception = true
9
9
 
10
+ def get_process_parent_pid(pid)
11
+ path = File.join("/proc", pid.to_s, "status")
12
+ if File.exists? path
13
+ ppid_line = File.read(path).lines.find {|line| line.split("\t").first == "PPid:"}
14
+ ppid = ppid_line.strip.split("\t").last.to_i
15
+
16
+ # zero is nil
17
+ ppid if ppid != 0
18
+ end
19
+ end
20
+
21
+ def process_alive?(pid)
22
+ begin
23
+ Process.kill(0, pid)
24
+ true
25
+ rescue ::Errno::EPERM
26
+ true
27
+ rescue ::Errno::ESRCH
28
+ # no such process
29
+ false
30
+ end
31
+ end
32
+
33
+ def get_parents
34
+ pid = Process.pid
35
+ parents = []
36
+
37
+ loop do
38
+ ppid = get_process_parent_pid(pid)
39
+ break unless ppid
40
+ parents << ppid
41
+ pid = ppid
42
+ end
43
+
44
+ parents
45
+ end
46
+
47
+ def set_gitlab_cancel_handler
48
+ parents_pids = get_parents
49
+
50
+ Thread.new do
51
+ loop do
52
+ cancelled = false
53
+
54
+ parents_pids.each do |pid|
55
+ if not process_alive? pid
56
+ File.open(File.join(ENV["HOME"], ".dapp", "cancelled"), "a") do |file|
57
+ file.write "#{Process.pid}\n"
58
+ end
59
+
60
+ Process.kill("INT", Process.pid)
61
+ cancelled = true
62
+ end
63
+ end
64
+
65
+ break if cancelled
66
+
67
+ sleep 1
68
+ end
69
+ end
70
+ end
71
+
72
+ set_gitlab_cancel_handler if ENV["GITLAB_CI"]
73
+
10
74
  begin
11
75
  begin
12
76
  begin
data/lib/dapp/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = "0.31.4"
2
+ VERSION = "0.31.5"
3
3
  BUILD_CACHE_VERSION = 30
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.4
4
+ version: 0.31.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout