Skip to contents

Kills the background process tree started by deck_serve() – kill_tree(), not kill(): uv run -m deckifyr serve is a real parent/child pair (uv spawns python -m deckifyr/uvicorn as a genuine child process, confirmed directly, not something that exec-replaces itself), so killing only the tracked top-level PID left the actual server running, orphaned, still bound to the port – a real bug this fixes, not a hypothetical (see deck_serve()'s own pre-flight-port-check comment for the confusing symptom it caused).

Usage

deck_stop_server(server = NULL, port = NULL, host = "127.0.0.1")

Arguments

server

A deckifyr_server object returned by deck_serve(). Exactly one of server/port must be supplied.

port

Stop whatever deckifyr server is listening on this port instead, without needing its deckifyr_server object. Exactly one of server/port must be supplied.

host

Host to check when stopping by port. Default "127.0.0.1", ignored when server is supplied (its own $host is used instead).

Value

server, invisibly, when stopping by server; invisible(NULL) when stopping by port (there's no handle to return).

Details

Pass port instead of server to stop a deckifyr server whose deckifyr_server handle no longer exists in this R session – unlike shiny::runApp(), which hangs the calling session so interrupting that is what stops the app, deck_serve() deliberately returns control immediately (spec section 12.0's own shiny::runApp()-like, not identical, mental model), so it's easy to lose track of the object (a session restart, an overwritten variable, ...) while the server itself keeps running. This form looks up whatever's listening on host:port (.pids_listening_on_port()) and refuses (with a clear error, not a silent no-op) to kill it unless its command line actually looks like a deckifyr server (.pid_looks_like_deckifyr_server()) – it will never kill an unrelated process just because it happens to occupy that port.

Examples

if (FALSE) { # \dontrun{
server <- deck_serve(project = "my-deck")
deck_stop_server(server)

# Or, if you've lost the `server` object but know the port:
deck_stop_server(port = 8000)
} # }