* Add PID file tracking and `unsloth studio stop` command
On macOS the .app shortcut launches Studio via osascript into a
Terminal window, then the launcher script exits. The server process
runs outside of the launcher's context with no PID file, so there
is no straightforward way to find or stop it.
This adds:
- PID file at ~/.unsloth/studio/studio.pid, written after the
server starts and removed on graceful shutdown or via atexit
- `unsloth studio stop` command that reads the PID file and sends
SIGTERM (or taskkill on Windows) to shut down the server
The PID file is only removed if it still contains the current
process ID, avoiding races when a new server instance replaces
a crashed one.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Move atexit PID cleanup into run_server()
The atexit registration was only in the __main__ block, so it
did not cover the `unsloth studio` CLI path that calls
run_server() directly via studio_default(). Moving it into
run_server() ensures the PID file is cleaned up on unexpected
exit regardless of entry point.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>