server-stop

Stops the PM2 dev server and removes orphan processes.

19|3|Updated Jul 19, 2024
One-click install
npx skills add https://github.com/danielterra/FOUNDATION --skill server-stop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: server-stop
Source: https://github.com/danielterra/FOUNDATION/tree/main/.claude/skills/server-stop
Command: npx skills add https://github.com/danielterra/FOUNDATION --skill server-stop

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Stops the foundation-dev server managed by PM2, including orphan child cleanup (FOUNDATION.exe / cargo). Use when the user asks to stop the server or Claude needs a clean shutdown.

Core Features & Use Cases

  • Stops the PM2 process foundation-dev and guarantees no orphan children survive.
  • Orphan sweep (MANDATORY) — PM2 kills the npm root; on Windows the spawned tree: cargo.exe, FOUNDATION.exe, vite node child may survive:
    • Get-Process FOUNDATION -ErrorAction SilentlyContinue => Stop-Process -Name FOUNDATION -Force if present.
    • Check for a leftover cargo watcher: Get-Process cargo -ErrorAction SilentlyContinue => kill ONLY if its Path is under this repo's target\ or it has no other plausible owner — never kill the user's unrelated cargo builds.
  • Verify — both pm2 jlist (no foundation-dev) and Get-Process FOUNDATION (empty) confirm shutdown.
  • Report — what was stopped and which orphans (if any) were cleaned.

Rules

  • ALWAYS sweep orphans after pm2 stop — a surviving FOUNDATION.exe holds the DB and blocks the next start.
  • NEVER kill unrelated node/cargo processes — only the dev-server tree.

Quick Start

Use the server-stop skill to gracefully stop the development server and clean up orphan processes.

Frequently Asked Questions about server-stop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stop a PM2 dev server without leaving orphan processes on Windows?

To stop a PM2 dev server without leaving orphan processes on Windows, you must kill the PM2 root process and then sweep surviving children like FOUNDATION.exe or cargo.exe. This guarantees no orphan processes hold the database or block restarts.

Why does FOUNDATION.exe survive after I stop the PM2 process?

FOUNDATION.exe survives a PM2 stop because PM2 only kills the npm root process, leaving the spawned Windows process tree orphaned. You must manually check Get-Process FOUNDATION and force kill it to release the database lock.

How do I clean up orphan cargo processes after stopping a dev server?

To clean up orphan cargo processes after stopping a dev server, check for surviving cargo watchers and kill them only if their path is under the repo's target directory. Never kill unrelated cargo builds that belong to other projects.

What is the best way to verify a PM2 server shutdown is complete?

The best way to verify a PM2 server shutdown is complete is to check both pm2 jlist for the absence of the process and Get-Process FOUNDATION to confirm no surviving executables remain. This ensures a fully clean shutdown.

When should I stop my dev server and clean up orphan child processes?

You should stop your dev server and clean up orphan child processes when transitioning between development workflows or when a clean shutdown is required. This prevents database locks and ensures the next server start is not blocked by lingering processes.

Can I use PM2 to manage and stop a Rust and Node.js dev server stack?

Yes, you can use PM2 to manage and stop a Rust and Node.js dev server stack. PM2 handles the root npm process, but you must manually sweep the spawned Windows child tree including cargo.exe and FOUNDATION.exe to ensure a clean shutdown.