Home

Daemon Guide

Server administration, configuration, authentication management, and deployment strategies.

This guide covers the administration, configuration, and management of the Shellwire WebSocket daemon.

Installation & Bootstrap

You can install Shellwire globally or in a virtual environment.

Pip Installation

pip install shellwire

Source & Auto-Venv

If running from source, Shellwire includes bootstrap scripts that automatically create a virtual environment (venv) and install dependencies:

  • Unix / Linux: ./run.sh
  • Windows: run.bat

Daemon Management

The shellwire CLI provides commands to manage the daemon’s lifecycle.

CommandDescription
shellwire startStarts the daemon in the foreground.
shellwire start --daemonForks the daemon to the background (POSIX only).
shellwire stopSends SIGTERM to the running daemon to shut it down gracefully.
shellwire statusChecks if the daemon is currently running.
shellwire versionPrints the current Shellwire version.

[!TIP] Use shellwire run as a convenient alias for shellwire start (without the daemon flag).

Configuration Flags

Configuration is handled via CLI flags when starting the daemon.

FlagDefaultDescription
--host127.0.0.1Bind address for the WebSocket server.
--port7842Port to listen on.
--log-levelINFOLogging verbosity (DEBUG, INFO, WARNING, ERROR).

Data files (logs, tokens, PIDs) are stored persistently in ~/.shellwire/.

Authentication & Tokens

Shellwire uses a stable token authentication system. The authentication token is a 64-character cryptographically secure hex string.

  • Generation: The token is generated once upon the first daemon start and persists across restarts.
  • Storage: Stored locally in ~/.shellwire/auth.token.

Token Commands

CommandDescription
shellwire token showDisplays the current stable auth token.
shellwire token rotateGenerates a new token, instantly invalidating the old one. Requires daemon restart to take effect.

Client Connection Management

The daemon tracks connected clients and allows administrators to forcefully revoke access.

CommandDescription
shellwire clients listDisplays a table of all known clients, their connection status, and last seen timestamps.
shellwire clients revoke <id>Immediately revokes access for the specified client_id.

[!WARNING] Revoking an actively connected client will forcibly disconnect them upon their next request. They will not be able to reconnect using that ID.

Advanced Features

Idle Session Timeout

To preserve system resources (especially on mobile environments like Termux where phantom process killers are aggressive), Shellwire automatically monitors interactive sessions. Sessions with no client input for over 1 hour (3600 seconds) are automatically terminated.

Graceful Shutdown

When shellwire stop is called, the daemon executes a multi-stage shutdown:

  1. Stops accepting new commands.
  2. Sends a daemon_stopping notification to the connected client.
  3. Waits for a 5-second grace period for active commands to finish.
  4. Sends SIGTERM followed by SIGKILL to all remaining process groups.