CLI Usage

    Tiny SSE

    A programmable server for Server-Sent Events (SSE).

    Usage

    tinysse [OPTIONS]
    

    Options

    NOTE: Options can be set via environment variables by prefixing the option name with TINYSSE_ and converting it to uppercase (e.g., --log-level becomes TINYSSE_LOG_LEVEL). Options set via command-line arguments take precedence over environment variables.

    -l, --listen <ADDR:PORT>

    [env: TINYSSE_LISTEN=]
    [default: 127.0.0.1:1983]

    The address and port for the HTTP server to listen.

    -L, --log-level <LEVEL>

    [env: TINYSSE_LOG_LEVEL=]
    [default: info]

    The logging level for the server. Possible values: error, warn, info, debug, trace.

    -k, --keep-alive <INTERVAL>

    [env: TINYSSE_KEEP_ALIVE=]
    [default: 60s]

    The interval between keep-alive messages sent to clients (e.g., 60s, 2m). Keep-alive messages are sent periodically to ensure that clients remain connected.

    -K, --keep-alive-text <TEXT>

    [env: TINYSSE_KEEP_ALIVE_TEXT=]
    [default: keep-alive]

    The text of the keep-alive comment sent to clients.

    -t, --timeout <TIMEOUT>

    [env: TINYSSE_TIMEOUT=]
    [default: 5m]

    The timeout duration for subscriber connections (e.g., 5m, 300s, 10m). Connections open for longer than this duration will be closed.

    -r, --timeout-retry <RETRY>

    [env: TINYSSE_TIMEOUT_RETRY=]
    [default: 0s]

    The retry delay sent to clients after a connection timeout (e.g., 0s, 2s). This delay instructs clients how long to wait before attempting to reconnect. Setting this to 0s instructs the client to reconnect immediately.

    -c, --capacity <CAPACITY>

    [env: TINYSSE_CAPACITY=]
    [default: 256]

    The capacity of the server's internal message queue.

    -s, --script <FILE_PATH>

    [env: TINYSSE_SCRIPT=]

    The path to a Lua script for server customization.

    --script-data <DATA>

    [env: TINYSSE_SCRIPT_DATA=]

    Optional data to pass to the Lua script as the cli.script_data value in the startup(cli) function.

    --script-tick <INTERVAL>

    [env: TINYSSE_SCRIPT_TICK=]
    [default: 500ms]

    The interval between Lua script ticks (e.g., 1s, 500ms). The script tick is a periodic event that allows the Lua script to perform background tasks in the tick(count) function.

    --unsafe-script

    [env: TINYSSE_UNSAFE_SCRIPT=]

    Allow the Lua script to load (require) native code, such as shared (.so) libraries. Enabling this can pose security risks, as native code can execute arbitrary operations. Use this option only if you trust the Lua script and need it to load native modules.

    -m, --max-body-size <BYTES>

    [env: TINYSSE_MAX_BODY_SIZE=]
    [default: 64KB]

    The maximum size of the publish request body that the server will accept (e.g., 32KB, 1MB).

    -P, --pub-path <URL_PATH>

    [env: TINYSSE_PUB_PATH=]
    [default: /sse]

    The URL path for publishing messages via POST.

    -S, --sub-path <URL_PATH>

    [env: TINYSSE_SUB_PATH=]
    [default: /sse]

    The URL path for subscribing to messages via GET.

    -D, --serve-static-dir <DIR_PATH>

    [env: TINYSSE_SERVE_STATIC_DIR=]

    Serve static files from the specified directory under the path specified by --serve-static-path.

    -U, --serve-static-path <URL_PATH>

    [env: TINYSSE_SERVE_STATIC_PATH=]
    [default: /]

    The URL path under which to serve static files from the directory specified by --serve-static-dir.

    --cors-allow-origin <ORIGINS>

    [env: TINYSSE_CORS_ALLOW_ORIGIN=]
    [default: *]

    Set Access-Control-Allow-Origin header to the specified origin(s).

    --cors-allow-methods <METHODS>

    [env: TINYSSE_CORS_ALLOW_METHODS=]
    [default: "GET, HEAD, POST"]

    Set Access-Control-Allow-Methods header to the specified method(s).

    --cors-allow-headers <HEADERS>

    [env: TINYSSE_CORS_ALLOW_HEADERS=]
    [default: *]

    Set Access-Control-Allow-Headers header to the specified header(s). (e.g., Cookie, Authorization).

    --cors-allow-credentials

    [env: TINYSSE_CORS_ALLOW_CREDENTIALS=]

    Set Access-Control-Allow-Credentials header to true.

    NOTE: Cannot be set if Access-Control-Allow-Origin or Access-Control-Allow-Headers is set to * (any).

    --cors-max-age <DURATION>

    [env: TINYSSE_CORS_MAX_AGE=]
    [default: 0s]

    Set Access-Control-Max-Age header to the specified duration (e.g., 1h, 60s).

    -h, --help

    Print help (see a summary with -h).

    -V, --version

    Print version.