예제 #1
0
def init_server(server_name: str):
    """
    Init OSRM server
    :param server_name: name of server to initialize
    """
    osrm_controller = OsrmController.get_controller_from_redis()
    osrm_controller.init_osrm_server(osrm_controller.get_server_id(server_name))
예제 #2
0
def restart(server_name: str):
    """
    Task to restart OSRM server.
    """
    osrm_controller = OsrmController.get_controller_from_redis()

    server_id = osrm_controller.get_server_id(server_name)
    osrm_controller.restart_osrm_server(server_id)
예제 #3
0
def extract(server_name: str):
    """
    Task to extract OSRM data.
    """
    osrm_controller = OsrmController.get_controller_from_redis()

    server_id = osrm_controller.get_server_id(server_name)
    osrm_controller.extract_osm_data(server_id)
    osrm_controller.save_osrm_data(server_id)
예제 #4
0
def contract(server_name: str, traffic_data: Optional[str] = None):
    """
    Task to contract with traffic data.

    :param traffic_data: Contents of the traffic CSV file (as defined by Project OSRM)
    """
    osrm_controller = OsrmController.get_controller_from_redis()

    server_id = osrm_controller.get_server_id(server_name)

    osrm_controller.restore_osrm_data(server_id)
    osrm_controller.contract_osm_data(server_id, traffic_data=traffic_data)
예제 #5
0
 def status():
     """Status of OSRM servers"""
     # need to load controller from Redis as server process IDs could have changed
     # if OSRM server was restarted since creation of API
     recent_osrm_controller = OsrmController.get_controller_from_redis()
     return recent_osrm_controller.status()