ruby-cli-daemon 0.5.1 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f33bf0fa02342563b3912182815e490db8934c52ec045583a6cd9a8c1166d41
4
- data.tar.gz: bce806f729afb0c0d62919a36c41ca099b693db2ddeb1a948cbff3df8710205c
3
+ metadata.gz: ad2a52af973971b5e06793e238c50769862f3e2383991468a6b21274cf8ea8a8
4
+ data.tar.gz: 7453617bab109f3d16820e7bc70ecfcaefcb38658854f1e608578ee9235b538a
5
5
  SHA512:
6
- metadata.gz: 4aa561f49f073c1ed7343fc5fc58ad6ad38cfbd8b168729a4442bebbba93410fb6faf4e465a4b2941c9ee31eb1e9277e7de2c163e7e964b815f37439ee408192
7
- data.tar.gz: 4807336c0ee7689c13b26d2f88982c93b39399f355debd4be13475ac2f886eae00143e045da0b35bd75f4f7958cc9d805f5abbd952127acb3afeacb6b75c3aa1
6
+ metadata.gz: 42f3da455b7f5baf303365b6f618b01f4008696f8047675defeefd4a1c2ef23921752beda43485e540e7549e78f841f0bb628f7949d70a35134b340a73f9d3c4
7
+ data.tar.gz: '09b540b23e636b7a9c0047f010de2da0b2e8c50b4ab3f2d386925c0cf20704e9576188c3cd91322a6b0b8e03c192540c6634bf3e3afdeb0c25cd2446cc255051'
@@ -48,9 +48,10 @@ if [[ ! -e $socket ]]; then
48
48
  done
49
49
  fi
50
50
 
51
- # prepare output so we can start tailing
51
+ # clear previous exit and pid
52
52
  status="${socket}.status"
53
- rm -f $status # clear previous
53
+ pid="${socket}.pid"
54
+ rm -f $status $pid
54
55
 
55
56
  # send IOs / command / env ... TODO: use perl or awk or bash to be faster ... see experiments/send_io.sh
56
57
  ruby --disable-gems -rsocket -rshellwords -e "
@@ -62,6 +63,11 @@ ruby --disable-gems -rsocket -rshellwords -e "
62
63
  s.print ENV.map { |k, v| %(#{k} #{v}) }.join('--RCD--')
63
64
  " -- "$@"
64
65
 
66
+ # pass HUP INT QUIT PIPE TERM to the child process
67
+ # - substract 128 which bash adds
68
+ # - we cannot send 2, so we send 15 instead which is pretty close
69
+ trap 'ex=$(expr $? - 128); if [[ "$ex" = "2" ]]; then ex=15; fi; echo $ex; kill -$ex $(cat $pid)' 1 2 3 13 15
70
+
65
71
  # wait for command to finish, tight loop so we don't lose time TODO: open another socket to be faster/efficient?
66
72
  while [ ! -f $status ]; do sleep 0.02; done
67
73
 
@@ -21,12 +21,13 @@ module RubyCliDaemon
21
21
 
22
22
  # execute the gems binary in a fork
23
23
  _, status = Process.wait2(fork do
24
+ File.write("#{socket}.pid", Process.pid) # uncovered
24
25
  replace_env server # uncovered
25
26
  load path # uncovered
26
27
  end)
27
28
 
28
29
  # send back exit status
29
- File.write("#{socket}.status", status.exitstatus)
30
+ File.write("#{socket}.status", status.exitstatus || 127)
30
31
  end
31
32
  ensure
32
33
  # signal that this program is done so ruby-sli-daemon.sh restarts it
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module RubyCliDaemon
3
- VERSION = "0.5.1"
3
+ VERSION = "0.6.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-cli-daemon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-08 00:00:00.000000000 Z
11
+ date: 2019-06-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it