ruby-cli-daemon 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ruby-cli-daemon.sh +8 -2
- data/lib/ruby_cli_daemon.rb +2 -1
- data/lib/ruby_cli_daemon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad2a52af973971b5e06793e238c50769862f3e2383991468a6b21274cf8ea8a8
|
4
|
+
data.tar.gz: 7453617bab109f3d16820e7bc70ecfcaefcb38658854f1e608578ee9235b538a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f3da455b7f5baf303365b6f618b01f4008696f8047675defeefd4a1c2ef23921752beda43485e540e7549e78f841f0bb628f7949d70a35134b340a73f9d3c4
|
7
|
+
data.tar.gz: '09b540b23e636b7a9c0047f010de2da0b2e8c50b4ab3f2d386925c0cf20704e9576188c3cd91322a6b0b8e03c192540c6634bf3e3afdeb0c25cd2446cc255051'
|
data/bin/ruby-cli-daemon.sh
CHANGED
@@ -48,9 +48,10 @@ if [[ ! -e $socket ]]; then
|
|
48
48
|
done
|
49
49
|
fi
|
50
50
|
|
51
|
-
#
|
51
|
+
# clear previous exit and pid
|
52
52
|
status="${socket}.status"
|
53
|
-
|
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
|
|
data/lib/ruby_cli_daemon.rb
CHANGED
@@ -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
|
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.
|
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-
|
11
|
+
date: 2019-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|