Repository navigation
Conversation
…cu#265) An unexpected exit used to leave a modal alert and a dead server, so a model that hit an out-of-memory kill or a driver hiccup stayed down until someone noticed. Settings > Server gains "If the server exits on its own": Ask (the old behaviour, default), Restart, and Restart + Notify. `CrashRestartPolicy` is pure and unit-tested: delays of 1, 2, 4, 8, 16 and 30 seconds, six attempts, and the streak reset by a run that stayed up for two minutes, so a crash loop still stops with the model's own error instead of restarting forever. Stop cancels a pending relaunch, and a manual Start wins over it with the model and flags the user just picked. The relaunch REPLAYS the recorded launch arguments rather than re-deriving them from the current form, and backoff counts from the moment the process reported healthy, not from launch. An exit 0 while nominally running is not a crash: the alert says "mlx-serve exited" instead of claiming a failure.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #265. When the server process died on its own the app raised a modal alert and stayed down, so a model that hit an out-of-memory kill or a transient driver failure needed a human to notice and press Start. Settings > Server gains one row, "If the server exits on its own", with three choices: Ask (today's alert, default), Restart, and Restart + Notify.
What changed
app/Sources/MLXServe/Services/CrashRecovery.swift(new) holds the whole policy as pure values, so the behaviour is testable without a real process:CrashRecoveryMode(.ask/.restartQuietly/.restartAndTellMe) is a display preference inUserDefaults(crashRecoveryMode), deliberately not aServerOptionsfield, since there is no CLI flag for it and it must not make the launch form dirty.CrashRestartPolicywaits 1, 2, 4, 8, 16 then 30 seconds, six attempts in total. A run that stayed up for two minutes counts as healthy and clears the streak, so a crash loop still stops and shows the model's own error instead of restarting forever.reaction(mode:canRelaunch:uptime:)folds the streak reset into the decision, which is why it is the only thingServerManagerhas to trust.CrashRecoveryNotifierposts a soundless local notification for the+ Notifymode, bundle-guarded the same wayTaskNotifieris soswift testnever touchesUNUserNotificationCenter.ServerManager:transitionToRunning()stampsrunningSince, so the backoff counts from the moment the server was actually healthy rather than fromexec, keeping a slow model load from being read as an instant crash.handleTerminationnow distinguishes four cases: unexpected exit while running, a recovery relaunch that died before reporting healthy (same streak, keep backing off), a first start that failed (still "Failed to start"), and exit 0 while nominally running, which is not a crash, so the alert reads "mlx-serve exited" instead of claiming a failure.SettingsView: oneSettingsRowwith a menuPicker. No dirty-tracking, because it is not a launch option and the form's Reset to Defaults does not own it.koandzh-Hanscatalogs carry the new strings.Verification
bash app/test.sh: 4,194 tests, 35 skipped, 0 failures, including ten newCrashRecoveryPolicyTestscases: the.askno-op, both automatic modes, no-replay-args falling back to the alert, the full[1, 2, 4, 8, 16, 30]ladder and its exhaustion, the streak reset by a healthy run, a short-lived run continuing the streak, the 120 s stability boundary, explicit reset, the raw-value round-trip with an unknown value landing on.ask, and the default mode.LocalizationTestsandKoreanLocalizationTestspass with the new keys.I did not touch
CHANGELOG.md, since it is written per release. No Zig sources or engine behaviour change.Opened as a draft: #978 asks for new PRs to wait for the big rewrite to land. The change is a single new file plus two surgical edits to existing call sites (
start/startHeadless/stop/handleTermination), so it should re-base cleanly, and I can rebase it on request once #978 is merged.Agent acting on behalf of @ianalitis