You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-23Lines changed: 9 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,27 +64,17 @@ To have more precise control over input and output, you can provide a custom clo
64
64
```swift
65
65
importSubprocess
66
66
67
-
let result =tryawaitrun(
68
-
.path("/bin/dd"),
69
-
arguments: ["if=/path/to/document"]
70
-
) { execution in
71
-
var contents =""
72
-
fortryawait chunk in execution.standardOutput {
73
-
let string = chunk.withUnsafeBytes { String(decoding: $0, as: UTF8.self) }
74
-
contents += string
75
-
if string =="Done" {
76
-
// Stop execution
77
-
await execution.teardown(
78
-
using: [
79
-
.gracefulShutDown(
80
-
allowedDurationToNextStep: .seconds(0.5)
81
-
)
82
-
]
83
-
)
84
-
return contents
67
+
// Monitor Nginx log via `tail -f`
68
+
asynclet monitorResult =run(
69
+
.path("/usr/bin/tail"),
70
+
arguments: ["-f", "/path/to/nginx.log"]
71
+
) { execution, standardOutput in
72
+
fortryawait line in standardOutput.lines(encoding: UTF8.self) {
73
+
// Parse the log text
74
+
if line.contains("500") {
75
+
// Oh no, 500 error
85
76
}
86
77
}
87
-
return contents
88
78
}
89
79
```
90
80
@@ -240,10 +230,6 @@ This option collects output as `[UInt8]`.
240
230
241
231
Use it by setting `.bytes` or `.bytes(limit:)` for `input` or `error`.
242
232
243
-
#### `SequenceOutput`:
244
-
245
-
This option redirects the child output to the `.standardOutput` or `.standardError` property of `Execution`. It’s only for the `run()` family that takes a custom closure.
0 commit comments