mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🏗 WIP: Functional services list
This commit is contained in:
@ -91,7 +91,7 @@
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--configuration:~/.phpmon_fconf_working.json"
|
||||
isEnabled = "YES">
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--configuration:~/.phpmon_fconf_broken.json"
|
||||
|
@ -17,54 +17,50 @@ class ValetServicesManager: ServicesManager {
|
||||
}
|
||||
|
||||
override func reloadServicesStatus() async {
|
||||
// TODO
|
||||
await withTaskGroup(of: [HomebrewService].self, body: { group in
|
||||
group.addTask {
|
||||
let rootServiceNames = self.formulae
|
||||
.filter { $0.elevated }
|
||||
.map { $0.name }
|
||||
|
||||
let rootJson = await Shell
|
||||
.pipe("sudo \(Paths.brew) services info --all --json")
|
||||
.out.data(using: .utf8)!
|
||||
|
||||
return try! JSONDecoder()
|
||||
.decode([HomebrewService].self, from: rootJson)
|
||||
.filter({ return rootServiceNames.contains($0.name) })
|
||||
}
|
||||
|
||||
group.addTask {
|
||||
let userServiceNames = self.formulae
|
||||
.filter { !$0.elevated }
|
||||
.map { $0.name }
|
||||
|
||||
let normalJson = await Shell
|
||||
.pipe("\(Paths.brew) services info --all --json")
|
||||
.out.data(using: .utf8)!
|
||||
|
||||
return try! JSONDecoder()
|
||||
.decode([HomebrewService].self, from: normalJson)
|
||||
.filter({ return userServiceNames.contains($0.name) })
|
||||
}
|
||||
|
||||
for await services in group {
|
||||
for service in services {
|
||||
guard let wrapper = self[service.name] else {
|
||||
break
|
||||
}
|
||||
|
||||
wrapper.service = service
|
||||
}
|
||||
}
|
||||
|
||||
for wrapper in serviceWrappers {
|
||||
wrapper.isBusy = false
|
||||
}
|
||||
|
||||
self.broadcastServicesUpdated()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
/*
|
||||
public static func loadHomebrewServices() async {
|
||||
await Self.shared.updateServicesList()
|
||||
|
||||
Task {
|
||||
let rootServiceNames = Self.shared.formulae
|
||||
.filter { $0.elevated }
|
||||
.map { $0.name }
|
||||
|
||||
let rootJson = await Shell
|
||||
.pipe("sudo \(Paths.brew) services info --all --json")
|
||||
.out.data(using: .utf8)!
|
||||
|
||||
let rootServices = try! JSONDecoder()
|
||||
.decode([HomebrewService].self, from: rootJson)
|
||||
.filter({ return rootServiceNames.contains($0.name) })
|
||||
|
||||
Task { @MainActor in
|
||||
for service in rootServices {
|
||||
Self.shared.services[service.name]!.service = service
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Task {
|
||||
let userServiceNames = Self.shared.formulae
|
||||
.filter { !$0.elevated }
|
||||
.map { $0.name }
|
||||
|
||||
let normalJson = await Shell
|
||||
.pipe("\(Paths.brew) services info --all --json")
|
||||
.out.data(using: .utf8)!
|
||||
|
||||
let userServices = try! JSONDecoder()
|
||||
.decode([HomebrewService].self, from: normalJson)
|
||||
.filter({ return userServiceNames.contains($0.name) })
|
||||
|
||||
Task { @MainActor in
|
||||
for service in userServices {
|
||||
Self.shared.services[service.name]!.service = service
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user