mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
🐛 Check if services command can run
This commit is contained in:
@ -18,4 +18,17 @@ struct HomebrewService: Decodable, Equatable {
|
|||||||
let status: String?
|
let status: String?
|
||||||
let log_path: String?
|
let log_path: String?
|
||||||
let error_log_path: String?
|
let error_log_path: String?
|
||||||
|
|
||||||
|
public static let serviceToCheck = "nginx"
|
||||||
|
public static func servicesCanBeLoaded() -> Bool {
|
||||||
|
let serviceInfo = try? JSONDecoder().decode(
|
||||||
|
[HomebrewService].self,
|
||||||
|
from: Shell.pipe(
|
||||||
|
"sudo \(Paths.brew) services info \(self.serviceToCheck) --json",
|
||||||
|
requiresPath: true
|
||||||
|
).data(using: .utf8)!
|
||||||
|
)
|
||||||
|
|
||||||
|
return serviceInfo != nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,13 @@ class Startup {
|
|||||||
breaking: true
|
breaking: true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
performEnvironmentCheck(
|
||||||
|
!HomebrewService.servicesCanBeLoaded(),
|
||||||
|
messageText: "startup.errors.services_json_error.title".localized,
|
||||||
|
informativeText: "startup.errors.services_json_error.desc".localized,
|
||||||
|
breaking: true
|
||||||
|
)
|
||||||
|
|
||||||
performEnvironmentCheck(
|
performEnvironmentCheck(
|
||||||
!Shell.pipe("cat /private/etc/sudoers.d/brew").contains("\(Paths.binPath)/brew"),
|
!Shell.pipe("cat /private/etc/sudoers.d/brew").contains("\(Paths.binPath)/brew"),
|
||||||
messageText: "startup.errors.sudoers_brew.title".localized,
|
messageText: "startup.errors.sudoers_brew.title".localized,
|
||||||
|
@ -78,7 +78,7 @@ class SiteListWC: PMWindowController, NSSearchFieldDelegate, NSToolbarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func showSitePopup(_ folder: String) {
|
func showSitePopup(_ folder: String) {
|
||||||
let storyboard = NSStoryboard(name: "Main" , bundle : nil)
|
let storyboard = NSStoryboard(name: "Main", bundle : nil)
|
||||||
|
|
||||||
let windowController = storyboard.instantiateController(
|
let windowController = storyboard.instantiateController(
|
||||||
withIdentifier: "addSiteWindow"
|
withIdentifier: "addSiteWindow"
|
||||||
|
@ -237,7 +237,7 @@ You can do this by running `composer global update` in your terminal. After that
|
|||||||
|
|
||||||
/// 6. Cannot retrieve services
|
/// 6. Cannot retrieve services
|
||||||
"startup.errors.services_json_error.title" = "Cannot determine services status";
|
"startup.errors.services_json_error.title" = "Cannot determine services status";
|
||||||
"startup.errors.services_json_error.desc" = "PHP Monitor was unable to check if any of the services are up and running. PHP Monitor usually queries `brew` using the following command: ``. PHP Monitor received an invalid response (no JSON).";
|
"startup.errors.services_json_error.desc" = "PHP Monitor was unable to check if some of the services are up and running.\n\nPHP Monitor usually queries `brew` using the following command to test if the services can be retrieved: `sudo brew services info nginx --json`. PHP Monitor received an invalid response (no JSON).";
|
||||||
|
|
||||||
/// 7. Multiple services active
|
/// 7. Multiple services active
|
||||||
"startup.errors.services.title" = "Multiple PHP services are active";
|
"startup.errors.services.title" = "Multiple PHP services are active";
|
||||||
|
Reference in New Issue
Block a user