osrm_stop_all: Stop all running OSRM servers started via this package

View source: R/osrm_stop_server.R

osrm_stop_allR Documentation

Stop all running OSRM servers started via this package

Description

[Stable]

Usage

osrm_stop_all(include_all = FALSE)

Arguments

include_all

A logical value. If TRUE, stop all OSRM servers found running on the system, including those not started by the current R session. Requires ps and jsonlite packages. Defaults to FALSE.

Value

The number of servers attempted.

Examples


if (identical(Sys.getenv("OSRM_EXAMPLES"), "true")) {
  install_dir <- osrm_install(
    version = "latest",
    path_action = "session",
    quiet = TRUE
  )

  pbf_path <- system.file("extdata/cur.osm.pbf", package = "osrm.backend")
  osrm_dir <- file.path(tempdir(), paste0("osrm-", Sys.getpid()))
  dir.create(osrm_dir, recursive = TRUE)
  tmp_pbf <- file.path(osrm_dir, "cur.osm.pbf")
  file.copy(from = pbf_path, to = tmp_pbf, overwrite = TRUE)
  graph <- osrm_prepare_graph(tmp_pbf, overwrite = TRUE, threads = 1L)

  srv <- osrm_start_server(graph$osrm_job_artifact, port = 6000, threads = 1L)
  stopped <- osrm_stop_all()
  stopped

  osrm_uninstall(
    dest_dir = install_dir,
    clear_path = TRUE,
    force = TRUE,
    quiet = TRUE
  )
  unlink(osrm_dir, recursive = TRUE)
}



osrm.backend documentation built on April 26, 2026, 9:06 a.m.