mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-03-26 06:00:07 +01:00
- RealWebApiTest requires api.phpmon.test to be reachable or skips - CommandTest requires php binary or skips
34 lines
739 B
Swift
34 lines
739 B
Swift
//
|
|
// URLReachable.swift
|
|
// PHP Monitor
|
|
//
|
|
// Created by Nico Verbruggen on 16/02/2026.
|
|
// Copyright © 2026 Nico Verbruggen. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class TestURL {
|
|
static func isReachable(url: String) -> Bool {
|
|
let process = Process()
|
|
|
|
process.executableURL = URL(fileURLWithPath: "/usr/bin/curl")
|
|
process.arguments = [
|
|
"-s", "-o", "/dev/null",
|
|
"--max-time", "3",
|
|
url
|
|
]
|
|
|
|
process.standardOutput = Pipe()
|
|
process.standardError = Pipe()
|
|
|
|
do {
|
|
try process.run()
|
|
process.waitUntilExit()
|
|
return process.terminationStatus == 0
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
}
|