1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-06 03:20:09 +02:00

🐛 Prevent timeout message from showing incorrectly

This commit is contained in:
2025-07-23 16:48:21 +02:00
parent 769779970b
commit e94377ebb1
6 changed files with 85 additions and 44 deletions

View File

@ -21,6 +21,10 @@
033D45A02B0D513900070080 /* RemovePhpExtensionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033D459D2B0D513900070080 /* RemovePhpExtensionCommand.swift */; };
033D45A12B0D513900070080 /* RemovePhpExtensionCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033D459D2B0D513900070080 /* RemovePhpExtensionCommand.swift */; };
033D45A32B0D531D00070080 /* PhpExtensionManagerView+Actions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 033D45A22B0D531D00070080 /* PhpExtensionManagerView+Actions.swift */; };
03BFF5272E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; };
03BFF5282E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; };
03BFF5292E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; };
03BFF52A2E312C3D007F96FA /* Startup+Timers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03BFF5262E312C39007F96FA /* Startup+Timers.swift */; };
03E36FE728D9219000636F7F /* ActiveShell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E36FE628D9219000636F7F /* ActiveShell.swift */; };
03E36FE828D9219000636F7F /* ActiveShell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E36FE628D9219000636F7F /* ActiveShell.swift */; };
5420395926135DC100FB00FA /* PreferencesVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5420395826135DC100FB00FA /* PreferencesVC.swift */; };
@ -920,6 +924,7 @@
033D45972B0D4EC600070080 /* InstallPhpExtensionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstallPhpExtensionCommand.swift; sourceTree = "<group>"; };
033D459D2B0D513900070080 /* RemovePhpExtensionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemovePhpExtensionCommand.swift; sourceTree = "<group>"; };
033D45A22B0D531D00070080 /* PhpExtensionManagerView+Actions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PhpExtensionManagerView+Actions.swift"; sourceTree = "<group>"; };
03BFF5262E312C39007F96FA /* Startup+Timers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Startup+Timers.swift"; sourceTree = "<group>"; };
03E36FE628D9219000636F7F /* ActiveShell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveShell.swift; sourceTree = "<group>"; };
5420395826135DC100FB00FA /* PreferencesVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesVC.swift; sourceTree = "<group>"; };
5420395E2613607600FB00FA /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
@ -1938,6 +1943,7 @@
C4B97B7A275CF20A003F3378 /* App+GlobalHotkey.swift */,
C4EED88827A48778006D7272 /* InterAppHandler.swift */,
C4D8016522B1584700C6DA1B /* Startup.swift */,
03BFF5262E312C39007F96FA /* Startup+Timers.swift */,
C495F5AE28A42E080087F70A /* EnvironmentCheck.swift */,
C40FE736282ABA4F00A302C2 /* AppVersion.swift */,
C409349C298EE8E900D25014 /* AppUpdater.swift */,
@ -2589,6 +2595,7 @@
C4EB53E528551F9B006F9937 /* HeaderView.swift in Sources */,
C4EA3C472BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */,
C40FE737282ABA4F00A302C2 /* AppVersion.swift in Sources */,
03BFF5282E312C3D007F96FA /* Startup+Timers.swift in Sources */,
C44A874828905BB000498BC4 /* ProgressVC.swift in Sources */,
C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */,
C456A0C62AA614BD0080144F /* PhpPreference.swift in Sources */,
@ -2892,6 +2899,7 @@
C490E3B929BCA368006D2DE6 /* App+BrewWatch.swift in Sources */,
C471E7FF28F9BAD10021E251 /* Xdebug.swift in Sources */,
C409349F298EE8E900D25014 /* AppUpdater.swift in Sources */,
03BFF5292E312C3D007F96FA /* Startup+Timers.swift in Sources */,
C471E7F228F9BAC70021E251 /* PhpEnvironments.swift in Sources */,
C471E7E628F9BAC20021E251 /* Process.swift in Sources */,
C471E81928F9BAE80021E251 /* NSMenuItemExtension.swift in Sources */,
@ -3078,6 +3086,7 @@
C4611E5A2AEAD2E20010BE24 /* ConfigManagerWindowController.swift in Sources */,
C471E80E28F9BAE80021E251 /* DateExtension.swift in Sources */,
C490E3BA29BCA368006D2DE6 /* App+BrewWatch.swift in Sources */,
03BFF5272E312C3D007F96FA /* Startup+Timers.swift in Sources */,
C471E7D028F9BA630021E251 /* FileSystemProtocol.swift in Sources */,
C471E81228F9BAE80021E251 /* TimeIntervalExtension.swift in Sources */,
C471E7DF28F9BAAB0021E251 /* RealCommand.swift in Sources */,
@ -3248,6 +3257,7 @@
C485706D28BF450900539B36 /* NSMenuItemExtension.swift in Sources */,
C481F79726164A78004FBCFF /* PreferencesVC.swift in Sources */,
C495F5B028A42E080087F70A /* EnvironmentCheck.swift in Sources */,
03BFF52A2E312C3D007F96FA /* Startup+Timers.swift in Sources */,
C41E871B2763D42300161EE0 /* DomainListVC+ContextMenu.swift in Sources */,
C40C7F3127722E8D00DDDCDC /* Logger.swift in Sources */,
C4068CAB27B0890D00544CD5 /* MenuBarIcons.swift in Sources */,
@ -3692,7 +3702,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1556;
CURRENT_PROJECT_VERSION = 1560;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
ENABLE_HARDENED_RUNTIME = YES;
@ -3704,7 +3714,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 25.06;
MARKETING_VERSION = 25.07;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -3722,7 +3732,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1556;
CURRENT_PROJECT_VERSION = 1560;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
ENABLE_HARDENED_RUNTIME = YES;
@ -3734,7 +3744,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 25.06;
MARKETING_VERSION = 25.07;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -3955,7 +3965,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1556;
CURRENT_PROJECT_VERSION = 1560;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
ENABLE_HARDENED_RUNTIME = YES;
@ -3967,7 +3977,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 25.06;
MARKETING_VERSION = 25.07;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) DEV";
@ -4071,7 +4081,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1556;
CURRENT_PROJECT_VERSION = 1560;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
ENABLE_HARDENED_RUNTIME = YES;
@ -4083,7 +4093,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 25.06;
MARKETING_VERSION = 25.07;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.dev;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) DEV";
@ -4187,7 +4197,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1556;
CURRENT_PROJECT_VERSION = 1560;
DEAD_CODE_STRIPPING = YES;
DEBUG = YES;
ENABLE_HARDENED_RUNTIME = YES;
@ -4199,7 +4209,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 25.06;
MARKETING_VERSION = 25.07;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) EAP";
@ -4366,7 +4376,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1556;
CURRENT_PROJECT_VERSION = 1560;
DEAD_CODE_STRIPPING = YES;
DEBUG = NO;
ENABLE_HARDENED_RUNTIME = YES;
@ -4378,7 +4388,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.5;
MARKETING_VERSION = 25.06;
MARKETING_VERSION = 25.07;
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon.eap;
PRODUCT_MODULE_NAME = PHP_Monitor;
PRODUCT_NAME = "$(TARGET_NAME) EAP";

View File

@ -18,6 +18,16 @@ struct Constants {
*/
static let MinimumRecommendedValetVersion = "2.16.2"
/**
The amount of seconds that is considered the threshold for
PHP Monitor to mark any given launch as a "slow" launch.
If the startup procedure was slow (or hangs), this message should
be displayed. This is based on an appropriate launch time on a
basic M1 Apple chip, with some margin for slower Intel chips.
*/
static let SlowBootThresholdInterval: TimeInterval = 30.0
/**
PHP Monitor supplies a hardcoded list of PHP packages in its own
PHP Version Manager.

View File

@ -0,0 +1,32 @@
//
// Startup+Timers.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 23/07/2025.
// Copyright © 2025 Nico Verbruggen. All rights reserved.
//
import Foundation
extension Startup {
@MainActor static var startupTimer: Timer?
@MainActor static var launchTime: Date?
@MainActor func startTimeoutTimer() {
Self.launchTime = Date()
Self.startupTimer = Timer.scheduledTimer(
timeInterval: Constants.SlowBootThresholdInterval, target: self,
selector: #selector(startupTimeout), userInfo: nil, repeats: false
)
}
@MainActor static func invalidateTimeoutTimer() {
let elapsedTime = Date().timeIntervalSince(Self.launchTime!)
let printableTime = String(format: "%.2f", elapsedTime)
Log.info("PHP Monitor launched quickly enough!")
Log.info("PHP Monitor boot time: \(printableTime) sec")
Self.startupTimer?.invalidate()
Self.startupTimer = nil
}
}

View File

@ -10,21 +10,6 @@ import AppKit
import NVAlert
class Startup {
@MainActor static var startupTimer: Timer?
@MainActor func startTimeoutTimer() {
Self.startupTimer = Timer.scheduledTimer(
timeInterval: 30.0, target: self, selector: #selector(startupTimeout),
userInfo: nil, repeats: false
)
}
@MainActor static func invalidateTimeoutTimer() {
Self.startupTimer?.invalidate()
Self.startupTimer = nil
}
/**
Checks the user's environment and checks if PHP Monitor can be used properly.
This checks if PHP is installed, Valet is running, the appropriate permissions are set, and more.

View File

@ -103,12 +103,6 @@ extension MainMenu {
// Find out which services are active
Log.info("The services manager knows about \(ServicesManager.shared.services.count) services.")
// Post-launch stats and update check, but only if not running tests
await performPostLaunchActions()
// Check if the linked version has changed between launches of phpmon
PhpGuard().compareToLastGlobalVersion()
// We are ready!
PhpEnvironments.shared.isBusy = false
@ -120,6 +114,9 @@ extension MainMenu {
// Check if we upgraded from a previous version
AppUpdater.checkIfUpdateWasPerformed()
// Post-launch stats and update check, but only if not running tests
await performPostLaunchActions()
}
/**
@ -127,18 +124,24 @@ extension MainMenu {
(This code is skipped when running SwiftUI previews.)
*/
private func performPostLaunchActions() async {
if !isRunningSwiftUIPreview {
Stats.incrementSuccessfulLaunchCount()
Stats.evaluateSponsorMessageShouldBeDisplayed()
if isRunningSwiftUIPreview {
return
}
if Stats.successfulLaunchCount == 1 {
Log.info("Should present the first launch screen!")
Task { @MainActor in
OnboardingWindowController.show()
}
} else {
await AppUpdater().checkForUpdates(userInitiated: false)
Stats.incrementSuccessfulLaunchCount()
Stats.evaluateSponsorMessageShouldBeDisplayed()
if Stats.successfulLaunchCount == 1 {
Log.info("Should present the first launch screen!")
Task { @MainActor in
OnboardingWindowController.show()
}
} else {
// Check for updates
await AppUpdater().checkForUpdates(userInitiated: false)
// Check if the linked version has changed between launches of phpmon
await PhpGuard().compareToLastGlobalVersion()
}
}

View File

@ -23,7 +23,7 @@ class PhpGuard {
Log.info("The currently linked version of PHP is: \(linked.version.short).")
}
public func compareToLastGlobalVersion() {
public func compareToLastGlobalVersion() async {
guard let currentVersion else {
return
}
@ -34,6 +34,7 @@ class PhpGuard {
Stats.persistCurrentGlobalPhpVersion(version: currentVersion)
return Log.warn("PHP Guard is saving the currently linked PHP version (first time only).")
}
Log.info("Previously, the globally linked PHP version was: \(previousVersion).")
if previousVersion == currentVersion {