mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-12-23 03:40:08 +01:00
👌 Cleanup
This commit is contained in:
@@ -136,12 +136,16 @@ class RealShell: ShellProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return try await withCheckedThrowingContinuation({ continuation in
|
return try await withCheckedThrowingContinuation({ continuation in
|
||||||
var timer: Timer?
|
let timer = Timer.scheduledTimer(withTimeInterval: timeout, repeats: false) { _ in
|
||||||
|
task.terminationHandler = nil
|
||||||
|
task.terminate()
|
||||||
|
return continuation.resume(throwing: ShellError.timedOut)
|
||||||
|
}
|
||||||
|
|
||||||
task.terminationHandler = { [timer, output] process in
|
task.terminationHandler = { [timer, output] process in
|
||||||
process.haltListening()
|
process.haltListening()
|
||||||
|
|
||||||
timer?.invalidate()
|
timer.invalidate()
|
||||||
|
|
||||||
if !output.err.isEmpty {
|
if !output.err.isEmpty {
|
||||||
return continuation.resume(returning: (process, .err(output.err)))
|
return continuation.resume(returning: (process, .err(output.err)))
|
||||||
@@ -150,12 +154,6 @@ class RealShell: ShellProtocol {
|
|||||||
return continuation.resume(returning: (process, .out(output.out)))
|
return continuation.resume(returning: (process, .out(output.out)))
|
||||||
}
|
}
|
||||||
|
|
||||||
timer = Timer.scheduledTimer(withTimeInterval: timeout, repeats: false) { _ in
|
|
||||||
task.terminationHandler = nil
|
|
||||||
task.terminate()
|
|
||||||
return continuation.resume(throwing: ShellError.timedOut)
|
|
||||||
}
|
|
||||||
|
|
||||||
task.launch()
|
task.launch()
|
||||||
task.waitUntilExit()
|
task.waitUntilExit()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ class ServicesManager: ObservableObject {
|
|||||||
|
|
||||||
let normalJson = await Shell
|
let normalJson = await Shell
|
||||||
.pipe("sudo \(Paths.brew) services info --all --json")
|
.pipe("sudo \(Paths.brew) services info --all --json")
|
||||||
.out
|
.out.data(using: .utf8)!
|
||||||
.data(using: .utf8)!
|
|
||||||
|
|
||||||
let normalServices = try! JSONDecoder()
|
let normalServices = try! JSONDecoder()
|
||||||
.decode([HomebrewService].self, from: normalJson)
|
.decode([HomebrewService].self, from: normalJson)
|
||||||
@@ -38,9 +37,7 @@ class ServicesManager: ObservableObject {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let userServiceNames = Preferences.custom.services else {
|
guard let userServiceNames = Preferences.custom.services else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let rootJson = await Shell
|
let rootJson = await Shell
|
||||||
.pipe("\(Paths.brew) services info --all --json")
|
.pipe("\(Paths.brew) services info --all --json")
|
||||||
|
|||||||
Reference in New Issue
Block a user