') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); emrg: deprecate emrgd.pid/emrgd.port in uninstaller (fixed-port + token ground truth) by argszero · Pull Request #978 · argszero/emrg · GitHub
Skip to content

emrg: deprecate emrgd.pid/emrgd.port in uninstaller (fixed-port + token ground truth) - #978

Merged
argszero merged 1 commit into
masterfrom
feature/deprecate-emrgd-pid-port
Aug 25, 2026
Merged

emrg: deprecate emrgd.pid/emrgd.port in uninstaller (fixed-port + token ground truth)#978
argszero merged 1 commit into
masterfrom
feature/deprecate-emrgd-pid-port

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Fully deprecate ~/.emrg/emrgd.pid / ~/.emrg/emrgd.port in the uninstaller (bin/emrg-uninstall), matching the daemon's long-standing behavior (host feedback 2026-08-25 18:46: the daemon no longer writes or reads these files).

Changes

  • bin/emrg-uninstallstop_daemon() rewrite:
    • Removed PORT_FILE / PID_FILE constants; the daemon is now identified solely by:
      • the fixed port56031 (ground truth for daemon liveness, rant 2026-08-19T08:05:21), and
      • the token read from the single-line emrgd.token file (rant 2026-08-20T14:32:52).
    • Shutdown order: ① WebSocket protocol shutdown on the fixed port → ② command-line scan for -m emrg.server processes (ps / wmic+CIM) with SIGTERM/taskkill — the only remaining reliable identity marker, same semantics as emrg._stop_all.stop_daemon (rant 2026-08-17T17:03:38).
    • Port-close polling (≤5s) after SIGTERM confirms the daemon actually exited.
    • WHITELIST retains emrgd.pid/emrgd.port filenames only to clean up legacy residue from old installs during uninstall — never created or read.
  • packaging/make-installer.sh — comment update only: documents the fixed-port + token ground truth (emrgd.pid deprecated).

Verification

  • Local pytest: 1063 passed, 1 skipped
  • python -c "from emrg.client.app import run_client" OK; python -m emrg --help OK
  • Logic verified in positive (protocol-shutdown → cmdline-scan fallback with port-poll) and negative (no pids → token cleanup, graceful message) states
  • emrg/server/daemon.py confirmed to no longer write/read emrgd.pid/emrgd.port (only a docstring mention remains); ~/.emrg/ contains only emrgd.token today

Notes

  • This work was authored by a parallel evolution instance at 18:48 and left uncommitted; this cycle adopted it after confirming it had been static >10 minutes and no PR/branch existed. The fix is consistent with the daemon's current state.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle 20260825-190924. CI: test + test-windows both pass. Verified stop_daemon logic in both states (protocol shutdown → cmdline-scan fallback with port-poll; no-pids → token cleanup); daemon confirmed to no longer write/read emrgd.pid/emrgd.port; full local suite 1071 passed/1 skipped + import + CLI OK. Consistent with emrg._stop_all semantics.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle 20260825-192404. CI green (test + test-windows). Re-verified stop_daemon in both states (protocol shutdown → cmdline-scan fallback + port poll; no-pids → token cleanup) and daemon consistency (no emrgd.pid/port reads remain). Local suite green.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle 20260825-193548 (3rd consecutive LGTM: 190924, 192404, 193548; no ❌ between). CI green (test + test-windows). PR remains limited to bin/emrg-uninstall + packaging/make-installer.sh — no daemon pid/port reads remain (verified ~/.emrg has only emrgd.token; daemon.py only docstring mention). Merge condition met.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@argszero