Skip to content

feat(worker): add graceful shutdown and zombie worker process reaper for sync-rpc - #754

Closed
thinhnx128 wants to merge 1 commit into
arakoodev:tsfrom
thinhnx128:feat/worker-graceful-shutdown-zombie-reaper
Closed

thinhnx128 wants to merge 1 commit into
arakoodev:tsfrom
thinhnx128:feat/worker-graceful-shutdown-zombie-reaper

Conversation

@thinhnx128

Copy link
Copy Markdown

Summary

Implements graceful shutdown (SIGTERM, SIGINT, SIGHUP) and automatic zombie worker / orphaned temporary directory reaping for EdgeChains worker processes:

Key Changes

  1. JS/wasm/sync-rpc/index.js — Active Worker Registry & Two-Phase Reaper:
    • Tracks spawned worker child processes in activeWorkers and installs idempotent signal handlers (exit, SIGINT, SIGTERM, SIGHUP).
    • Performs a two-phase teardown (SIGTERM followed by SIGKILL escalation after 1.5s if the worker remains hung) so background workers are never left orphaned holding TCP ports.
    • Passes EDGECHAINS_PARENT_PID to the child worker.
  2. JS/wasm/sync-rpc/worker.js — Parent Liveness Watchdog & Graceful Server Drain:
    • Polls parent liveness via process.kill(parentPid, 0) every 1s and triggers gracefulShutdown(0) if the parent process dies unexpectedly.
    • Adds SIGINT / SIGTERM handlers and a "shutdown" command that drains active connections via server.close() before exiting, while binding to loopback (127.0.0.1).
  3. JS/edgechains/arakoodev/src/sync-rpc/lib/sync-rpc.ts — Automatic Temp Directory Cleanup:
    • Registers sync-rpc-* temporary directories in activeTempDirs and cleans them up on process exit/signals (fs.rmSync(dir, { recursive: true, force: true })), plus exposes syncRPC.dispose().

@thinhnx128

Copy link
Copy Markdown
Author

I have read the Arakoo CLA Document and I hereby sign the CLA

@thinhnx128
thinhnx128 force-pushed the feat/worker-graceful-shutdown-zombie-reaper branch from a937f0a to 2bb5ffb Compare October 31, 2026 05:06
@thinhnx128

Copy link
Copy Markdown
Author

Closing this to reduce review load — it wasn't requested by the maintainers. Thanks for your time; happy to reopen if it's useful.

@thinhnx128 thinhnx128 closed this Nov 12, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant