mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
🐛 Disable www.conf
file when switching versions (#152)
This commit is contained in:
@ -42,6 +42,7 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
group.enter()
|
group.enter()
|
||||||
|
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
DispatchQueue.global(qos: .userInitiated).async {
|
||||||
|
self.disableDefaultPhpFpmPool(available)
|
||||||
self.stopPhpVersion(available)
|
self.stopPhpVersion(available)
|
||||||
group.leave()
|
group.leave()
|
||||||
}
|
}
|
||||||
@ -63,6 +64,21 @@ class InternalSwitcher: PhpSwitcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func disableDefaultPhpFpmPool(_ version: String) {
|
||||||
|
let pool = "\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf"
|
||||||
|
if FileManager.default.fileExists(atPath: pool) {
|
||||||
|
Log.info("A default `www.conf` file was found in the php-fpm.d directory for PHP \(version).")
|
||||||
|
let existing = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf")!
|
||||||
|
let new = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf.disabled-by-phpmon")!
|
||||||
|
do {
|
||||||
|
try FileManager.default.moveItem(at: existing, to: new)
|
||||||
|
Log.info("Success: A default `www.conf` file was disabled for PHP \(version).")
|
||||||
|
} catch {
|
||||||
|
Log.err(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func stopPhpVersion(_ version: String) {
|
private func stopPhpVersion(_ version: String) {
|
||||||
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
|
let formula = (version == PhpEnv.brewPhpVersion) ? "php" : "php@\(version)"
|
||||||
brew("unlink \(formula)")
|
brew("unlink \(formula)")
|
||||||
|
Reference in New Issue
Block a user