longmem stop command gracefully shuts down the memory daemon.
Syntax
What It Does
When you runlongmem stop, the CLI:
- Checks if daemon is running - Performs health check first
- Sends shutdown request - POST to
/shutdownendpoint - Waits for graceful shutdown - Allows daemon to clean up resources
Output
Successful Stop
Already Stopped
Failed to Stop
Graceful Shutdown Process
When the daemon receives a shutdown request, it:- Stops accepting new requests - Server stops listening
- Destroys idle detector - Cancels any pending timers
- Closes database connection - Ensures all writes are flushed
- Removes PID file - Cleans up
~/.longmem/longmem.pid - Exits process - Terminates with exit code 0
Under the Hood
The stop command sends an HTTP POST request to:Signal Handling
The daemon also responds to system signals:SIGTERM- Graceful shutdown (same as HTTP shutdown)SIGINT- Graceful shutdown (Ctrl+C)
Exit Codes
0- Daemon stopped successfully or was not running1- Failed to stop daemon
Troubleshooting
Daemon won’t stop
If the stop command fails, you can forcefully kill the process:Port still in use after stop
Check if the port is still bound:Database locked after stop
If the database appears locked after stopping:When to Stop the Daemon
Normal Operations
- System restart - The daemon doesn’t auto-start; stop before reboot
- Configuration changes - Some config changes require restart
- Troubleshooting - Stop, check logs, then start again
You Don’t Need to Stop
- Regular use - The daemon is designed to run continuously
- Low memory - Daemon uses minimal resources (typically <50MB)
- Battery - Idle daemon consumes negligible CPU
What Happens After Stop
After stopping:- PID file is removed
- HTTP server is stopped
- Database connection is closed
- All compression jobs are abandoned (will resume on next start)
- MCP tools and hooks will fail until daemon is restarted
Related Commands
longmem start- Start the daemonlongmem status- Check daemon statuslongmem logs- View daemon logs before stopping