Overview
Triggers a graceful shutdown of the LongMem daemon. The daemon will:- Stop accepting new requests
- Close the database connection
- Clean up the PID file
- Exit with status 0
Authentication
Requires Bearer token ifauthToken is configured in daemon settings.
Request
No request body required.Response
Always “shutting_down”
Example
cURL
Response
Use Cases
Programmatic Shutdown
Useful for scripts that manage the daemon lifecycle:Integration Cleanup
Some integrations may call this during uninstall or reconfiguration.Implementation Details
Fromdaemon/server.ts:175-179:
- Schedules shutdown 100ms after responding
- Calls the
shutdown()function which:- Destroys the idle detector
- Stops the HTTP server
- Closes the SQLite database
- Removes the PID file at
~/.longmem/longmem.pid - Exits the process
Comparison with CLI
Thelongmem stop CLI command also calls this endpoint internally (or sends SIGTERM).
| Method | Use Case |
|---|---|
longmem stop | Recommended for users |
POST /shutdown | For programmatic control |
kill <pid> | Emergency stop |
Safety Notes
- Graceful: Completes current request handling before shutting down
- No data loss: Database is properly closed with all pending writes flushed
- PID cleanup: Removes stale PID file automatically
Error Responses
Unauthorized
authToken is configured and missing/incorrect)
Related
- longmem stop - CLI command to stop the daemon
- longmem status - Check if daemon is running
- GET /health - Health check endpoint