File tree Expand file tree Collapse file tree 4 files changed +53
-5
lines changed Expand file tree Collapse file tree 4 files changed +53
-5
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,19 @@ local res, err = prog('some-program')
102
102
103
103
```
104
104
105
+ ### Treat timeouts as non-errors
106
+
107
+ By default, ` sockexec ` treats a timeout as an error. You can disable this by
108
+ setting the object's ` timeout_fatal ` key to false. Examples:
109
+
110
+ ``` lua
111
+ -- set timeout_fatal = false on the prog objects
112
+ prog .timeout_fatal = false
113
+
114
+ -- or, set it at calltime:
115
+ local res , err = prog ({argv = {' cat' }, timeout_fatal = false })
116
+ ```
117
+
105
118
### But I actually want a shell!
106
119
107
120
Not a problem! You can just do something like:
Original file line number Diff line number Diff line change 1
1
name = lua-resty-exec
2
- version = 1.1.2
2
+ version = 1.1.3
3
3
abstract = Run external programs in OpenResty without spawning a shell or blocking
4
4
author = John Regan
5
5
is_original = yes
Original file line number Diff line number Diff line change 18
18
19
19
20
20
local _M = {
21
- _VERSION = ' 1.1.2 '
21
+ _VERSION = ' 1.1.3 '
22
22
}
23
23
24
24
function _M .new (address )
@@ -32,7 +32,8 @@ function _M.new(address)
32
32
stdin = nil ,
33
33
stdout = nil ,
34
34
stderr = nil ,
35
- bufsize = 4096
35
+ bufsize = 4096 ,
36
+ timeout_fatal = true ,
36
37
}
37
38
38
39
function o .exec (self ,...)
@@ -52,6 +53,7 @@ function _M.new(address)
52
53
end
53
54
end
54
55
if args [1 ].stdin then self .stdin = args [1 ].stdin end
56
+ if args [1 ].timeout_fatal then self .timeout_fatal = args [1 ].timeout_fatal end
55
57
else
56
58
self .argv = args
57
59
end
@@ -80,8 +82,20 @@ function _M.new(address)
80
82
81
83
while (not err ) do
82
84
data , err , partial = c :receive (self .bufsize )
83
- if err and err ~= " closed" then
84
- return nil , err
85
+ if err then
86
+ if err == ' timeout' then
87
+ if self .timeout_fatal then
88
+ return nil , err
89
+ else
90
+ err = nil
91
+ end
92
+ else
93
+ if err ~= ' timeout' and err ~= ' closed' then
94
+ return nil , err
95
+ else
96
+ err = nil
97
+ end
98
+ end
85
99
end
86
100
87
101
if data then
Original file line number Diff line number Diff line change
1
+ package = " lua-resty-exec"
2
+ version = " 1.1.3-0"
3
+ source = {
4
+ url = " https://github.com/jprjr/lua-resty-exec/archive/1.1.3.tar.gz" ,
5
+ file = " lua-resty-exec-1.1.3.tar.gz"
6
+ }
7
+ description = {
8
+ summary = " Run external programs in OpenResty without spawning a shell" ,
9
+ homepage = " https://github.com/jprjr/lua-resty-exec" ,
10
+ license = " MIT"
11
+ }
12
+ build = {
13
+ type = " builtin" ,
14
+ modules = {
15
+ [" resty.exec" ] = " lib/resty/exec.lua"
16
+ }
17
+ }
18
+ dependencies = {
19
+ " lua >= 5.1" ,
20
+ " netstring >= 1.0.2"
21
+ }
You can’t perform that action at this time.
0 commit comments