Skip to content

Start Sunshine only through the user unit - #12358

Open
z23 wants to merge 5 commits into
omacom:quattrofrom
z23:fix/sunshine-single-autostart
Open

z23 wants to merge 5 commits into
omacom:quattrofrom
z23:fix/sunshine-single-autostart

Conversation

@z23

@z23 z23 commented Sep 18, 2026 •

Copy link
Copy Markdown

Fixes #12349.

`omarchy-install-service-sunshine` enabled the systemd user unit and appended `o.launch_on_start("sunshine")`. On login both copies started; the Hyprland/uwsm one aborted on TCP 47984 after the unit already had the port.

Autostart is the user unit alone now. A migration strips the leftover Hyprland line from existing installs; removal already deleted that line.

Verified with installer/removal source checks and a migration test against a fake `~/.config/hypr/autostart.lua`.

Fixes #7218

Fixes #7050

Fixes #12053

Fixes #12499

Fixes #12537

Fixes #13877

The installer also appended o.launch_on_start("sunshine"), so login
started a second copy that SIGABRTed on the already-bound GameStream port.

@paulogeyer paulogeyer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 — this is the right primary fix for #12349: drop the Hyprland double-start, migrate existing autostart.lua lines, and cover it with an in-tree test. Verified locally (installer no longer appends; migration strips only the sunshine line and is idempotent).

One small ask before merge: please also enable/disable the canonical unit app-dev.lizardbyte.app.Sunshine.service (as in #12472) instead of the sunshine alias, which can fail on a fresh enable. Happy to re-check once that’s in.

The sunshine alias is missing until the first successful enable, so a
fresh install can fail. Use app-dev.lizardbyte.app.Sunshine.service for
enable and disable.
@z23

z23 commented Sep 20, 2026

Copy link
Copy Markdown
Author

@paulogeyer Taken. Install now enable --nows app-dev.lizardbyte.app.Sunshine.service, and remove disables the same unit. The sunshine alias is no longer used for either, matching #12472.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 852979ea, and it works. Nothing found that needs changing.

Reproduced on a disposable Omarchy worker, with sunshine 2026.516.143833-4.1:

  • Base (quattro): the installer stops at systemctl --user enable --now sunshine, with "Unit sunshine.service does not exist" on a fresh install and "Refusing to operate on linked unit file sunshine.service" on a rerun. That means it currently can't write the Hyprland line, but installs from before the alias broke already have it. Recreating that state (unit enabled, plus o.launch_on_start("sunshine") in autostart.lua) and rebooting: Hyprland's copy took the ports, and the user unit aborted with Couldn't bind RTSP server to port [48010] five times (five SIGABRT core dumps) before systemd marked it failed.
  • Head: after running migrations/1789703649.sh on that machine and rebooting, one Sunshine ran, inside app-dev.lizardbyte.app.Sunshine.service, with 47984, 47990 and 48010 bound and no core dumps. A second run of the migration changed nothing, and other lines in autostart.lua were kept. A fresh remove, then install, then reinstall with the head scripts all exited 0 and wrote no Hyprland line, and after a reboot there was again one instance from the unit.
  • Tests: ./test/cli passed, and so did sunshine-autostart-test.sh (8/8), migrate-scope-test.sh, migrate-wrapper-test.sh and bin-style-test.sh. The new test fails against base, as it should.

Second opinion: Codex at medium effort reviewed the diff and found it proportionate, with no blocking defect; its review is not guaranteed to be independent of this one. It noted that the . in the migration's sed pattern is an unescaped wildcard. That isn't worth changing: the sed only runs once the exact line is there, the most it could also delete is another line that launches Sunshine, and the removal script already uses the same pattern.

Since this also fixes the alias failures, I've added links to #7050, #7218, #12053, #12499, #12537 and #13877 alongside #12349. #12472 fixes the double start too, but without a migration it doesn't reach machines that already carry the line. #8879, #12505, #13230, #13331 and #13925 only change the unit name, so they leave the double start in place. This one covers all of it.

Now waiting on the maintainer.

The test grepped the scripts' source, which passes for a script that names the canonical unit anywhere and still runs the alias. It now runs the installer and the remover against a mocked systemctl, as omacom#13925 does, and checks the commands they actually issue: the canonical unit is enabled and the alias never is, no Hyprland autostart line is written, a failed enable stops before the firewall and web app, removal disables the unit before dropping the package and strips a leftover line, and a failed disable still removes the package. Each failure scenario also asserts the call was made, so an unrelated early exit cannot pass it.

The installer backgrounds the admin web app launch, so the test waits for the mock launcher to run before asserting anything: a failure that removed the mocks first could let that child resolve the real omarchy-launch-webapp and open a browser on the machine running the suite.

Co-Authored-By: AnPod <drejc83@gmail.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one commit, 96d245bb, that changes only test/shell.d/sunshine-autostart-test.sh. The fix itself is unchanged from 852979ea.

Why: the test checked the scripts by grepping their source, so a script that named the canonical unit anywhere would pass even if it still ran the alias. #13925 by @AnPod tests the same scripts by running them, so its approach is adopted here and AnPod is credited as co-author. The installer and remover now run against a mocked systemctl and mocked helpers, and the test checks the commands they actually issue:

  • The installer enables app-dev.lizardbyte.app.Sunshine.service, never sunshine, and writes no o.launch_on_start("sunshine").
  • A failed enable stops before the firewall and web app steps.
  • Removal disables the unit before dropping the package, strips a leftover autostart line and keeps the user's other lines.
  • A failed disable still removes the package.
  • The migration checks from the original test are kept.

Tested on a disposable Omarchy worker: the new test passes on 96d245bb and fails on quattro and with the fix reverted. ./test/cli, migrate-scope-test.sh, migrate-wrapper-test.sh and bin-style-test.sh are green. With the real sunshine package, the head's installer enabled and started the canonical unit. The migration removed an autostart line planted to imitate an older install, and a reinstall wrote none. One Sunshine process was running with its three TCP ports bound, and there were no core dumps. Removal left no unit behind.

Second opinion: Codex at medium effort reviewed the new test over three rounds, and its findings changed the test, so it is credited as co-author too:

  • It noticed the rewrite had dropped the check that the sunshine alias is never enabled or disabled, and that the failure scenarios didn't confirm the call was made. Both are now asserted.
  • It pointed out that the installer's backgrounded web app launch could outlive the mocks if the test failed early, and then open a real browser on the machine running the suite. The test now waits for the mocked launcher before asserting anything.

Its last round, on 96d245bb, found nothing further. Its independence from this review is not guaranteed.

Now waiting on the maintainer.

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Sunshine now starts through its systemd user unit instead of two login paths.

  • Sunshine starts through one user unit instead of two login launchers.

Reviews (2) · Last reviewed commit: "Check failed Sunshine reinstalls keep th..." · Reviewed by Greptile

@jandrusk

Copy link
Copy Markdown

Verified direction looks right: enable the real unit app-dev.lizardbyte.app.Sunshine.service, drop the Hyprland o.launch_on_start("sunshine") double-start, and migrate existing autostart.lua lines away. That matches #14048 / #13877.

Heads-up on the cluster of open siblings doing the same unit-name fix: #13925, #14412, #12505, #13230. Worth picking one (this one already has the migration + remove path + tests) and closing the rest as duplicates once it merges.

@thedavidweng

Copy link
Copy Markdown

Confirmed on a real session, not only the disposable worker. This is the change that stops the crash we just traced.

Machine: Omarchy 4.5.0-3, Sunshine 2026.914.233613 (newer than the 2026.516 package in the review above). omarchy-install-service-sunshine enabled app-dev.lizardbyte.app.Sunshine.service and appended o.launch_on_start("sunshine") on 2026-10-27, while Hyprland was already running, so the second copy did not start until the next session.

On the boot at 2026-11-06 00:37:

  • 00:37:44 uwsm-app -- sunshine started the Hyprland scope and had the UI up on port 47990 by 00:37:45.
  • 00:37:49 the user unit (PID 4910), delayed by ExecStartPre=/bin/sleep 5, logged Fatal: Couldn't bind RTSP server to port [48010], Address already in use and SIGABRTed. The crashing thread (nvhttp::47984) is __cxa_throw → _Unwind_RaiseException → abort.
  • Hyprland's process was replaced at 01:06, autostart ran again, and the unit aborted three more times before start-limit-hit at 01:07:03.
  • The scope copy is the one still bound to 47984, 47989, 47990, and 48010. ~/.config/sunshine was not rewritten.

This patch matches that failure. Dropping enable_hyprland_autostart stops a new install from writing the second launcher, enable --now of app-dev.lizardbyte.app.Sunshine.service keeps the copy that should survive, and migrations/1789703649.sh deletes the exact line in this autostart.lua (o.launch_on_start("sunshine"), no extra whitespace). After that migration, the next login has one starter.

Filed by Grok 4.7 via Grok Build.

@omarchybot omarchybot removed the ready Good to merge label Nov 18, 2026
@morgoth

morgoth commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@omarchybot can we have this merged? Having the same issue

@omarchybot

Copy link
Copy Markdown
Collaborator

I read the four-file diff at 96d245bb098337198c847a154b0989aa8805644b, the linked reports, the comments, and the current quattro source and contributor rules. The branch is unchanged since the October worker verification.

GPT-6 in Codex (reasoning effort not exposed) classifies this as a bug fix. The configured classification reviewer, DeepSeek v4p1 Flash, returned no usable classification, so the required classification check is incomplete. No second technical review or new worker tests were completed in this pass, and no code was changed.

This pass stops at the classification check. Verification can resume after that check is completed; no action is requested from the author.

@omarchybot omarchybot added bug Something isn't working and removed bug Something isn't working labels Nov 18, 2026
omarchybot and others added 2 commits November 22, 2026 14:39
A user can disable the crashing unit and keep the Hyprland launcher as a workaround for the double start. The migration now removes that launcher only when the canonical unit is enabled, so an update preserves their sole startup path. An explicit reinstall enables the canonical unit and removes the legacy launcher, including when the migration previously preserved it. The existing installer test now starts with a legacy entry and catches a reinstall that leaves it behind.

Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
The enable-failure scenario now starts with the legacy launcher present and checks that it survives. Moving cleanup before a failed unit enable would otherwise remove the only startup path while leaving the existing failure assertions green.

Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Nov 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed 4c3b8f954ae8d75334e9e0b82f0b8b50c699b513 and d6b34bd23ff28a67b6f51996f5d8c03b5d795c0a to preserve startup on machines where the user disabled the systemd unit and kept the Hyprland launcher. The migration now keeps that sole launcher. An explicit reinstall enables the canonical unit before removing the legacy launcher; a failed enable leaves it intact.

Verified on a fresh disposable Omarchy worker with Sunshine 2026.914.233613-2 and systemd 262.2:

  • The base installer fails at the real alias enable, the fixed installer succeeds with the canonical unit, and reverting the installer reproduces the failure.
  • A login with both legacy launchers reproduces the RTSP 48010 bind failure and SIGABRT. After the migration and another login, one process runs under the canonical unit, all three TCP ports listen, and the unit has zero restarts and no bind failure or core dump in that boot.
  • With a real disabled unit, the old migration deletes the sole launcher, the fix preserves it, and reverting loses it again. Reinstall cleanup and preservation on enable failure also have checks that fail when their fixes are removed or reordered.
  • ./test/cli, the Sunshine tests, migration runner/wrapper tests, and command-style tests pass. The VM used wlr capture and software encoding to exercise startup; Moonlight streaming and hardware encoders were not tested.

GPT-6 in Codex (reasoning effort not exposed), Opus 5.5 High, and muse-wonder via pi at high thinking reviewed the change. Both final reviewers found the production code correct. Opus still objects to the migration tests already in this PR because the current repository rules prohibit them; muse-wonder found no remaining defect or coverage gap. The final readiness check also flags test size and maintenance cost. The three-round review limit is reached, so these findings remain for the maintainer. Agreement between these reviews is not guaranteed to be independent.

For comparison, #12271 has no cleanup of existing Hyprland entries, and #13230 still writes the second launcher and leaves removal using the alias. I read all seven linked reports against the final diff: the canonical-unit change covers the fresh and repeated-install failures, and the startup checks cover both double-start reports. Cleanup takes effect at the next login; it does not stop an already running legacy Sunshine process during the current session.

The fix carries verified. It is waiting on the maintainer's decision about the remaining test-policy finding.

@morgoth

morgoth commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

I confirm this fix works.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 27, 2026
@blegat

blegat commented Nov 29, 2026

Copy link
Copy Markdown

Just tested it on Omarchy 4.5.0-3, I can confirm that this fix works for me too.

@omarchybot

Copy link
Copy Markdown
Collaborator

GitHub now reports a conflict with quattro in bin/omarchy-remove-service-sunshine. Please update the branch, keeping the canonical unit, the removal status line from #20462, and the symlink handling from #20002. Apply the same symlink-preserving edit in the installer and migration. A scratch-file check confirmed that their current sed -i replaces the link and leaves the target untouched.

GPT-6 in Codex (effort not exposed), Opus 5.5 High and muse-wonder via pi, thinking high checked the source and reached the same conclusion. The reviews may share context. Worker preflight blocked a fresh test run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment