From e9fb70208a160c3df61ec1573afa7ca2875ea4d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Genevi=C3=A8ve=20Bastien?= Date: Thu, 3 Nov 2022 14:13:31 -0400 Subject: [PATCH] json2capnp: Make the cache path argument mandatory Now that the project shortname is not an environment variable anymore and that the project directory can be anywhere and not only in a projects/ directory, it is not possible de know this path from the .env file data. The absolute path must be set on the command as second argument For example, to run json2capnp for the example app, where the cache is in `examples/runtime/demo_transition` directory, the service can be run as `yarn start:json2capnp -- 2000 $PWD/examples/runtime/cache/demo_transition`, or `cd services/json2capnp && cargo run -- 2000 ../../examples/runtime/cache/demo_transition`. The dotenv and home packages are not required anymore. --- services/json2capnp/Cargo.lock | 17 ----------------- services/json2capnp/Cargo.toml | 2 -- services/json2capnp/src/main.rs | 14 +++----------- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/services/json2capnp/Cargo.lock b/services/json2capnp/Cargo.lock index ffe72424d..bb84b245f 100644 --- a/services/json2capnp/Cargo.lock +++ b/services/json2capnp/Cargo.lock @@ -304,12 +304,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dotenv" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" - [[package]] name = "filetime" version = "0.2.13" @@ -476,15 +470,6 @@ dependencies = [ "libc", ] -[[package]] -name = "home" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654" -dependencies = [ - "winapi", -] - [[package]] name = "httparse" version = "1.3.4" @@ -529,11 +514,9 @@ name = "json2capnp" version = "0.2.0" dependencies = [ "capnp", - "dotenv", "geo", "geobuf", "geojson", - "home", "json", "polyline", "pretty_assertions", diff --git a/services/json2capnp/Cargo.toml b/services/json2capnp/Cargo.toml index 5e302f1f5..1c1d5c860 100644 --- a/services/json2capnp/Cargo.toml +++ b/services/json2capnp/Cargo.toml @@ -10,8 +10,6 @@ capnp = "0.14" rouille = "3.0" serde_json = "1.0" uuid = "0.8" -dotenv = "0.15" -home = "0.5" polyline = "0.9" geo = "0.17.0" geojson = "0.22.0" diff --git a/services/json2capnp/src/main.rs b/services/json2capnp/src/main.rs index fafc5e490..2743a8ced 100644 --- a/services/json2capnp/src/main.rs +++ b/services/json2capnp/src/main.rs @@ -6,8 +6,6 @@ * */ -use dotenv; -use home; use rouille::Request; use rouille::Response; use std::fs; @@ -61,15 +59,9 @@ fn main() { println!("Starting json2capnp server..."); - // setup dotenv: - let my_env_path = home::home_dir() - .and_then(|a| Some(a.join("/../../../.env"))) - .unwrap(); - dotenv::from_path(my_env_path.as_path()).ok(); - let project_shortname = dotenv::var("PROJECT_SHORTNAME").unwrap(); - let project_cache_directory_path_str = cache_directory.unwrap_or(format!( - "../../projects/{}/cache/{}", project_shortname, project_shortname - )); + // TODO For now, the project cache directory must be set on the command line. It can come from config when config is json or yml (#415) + let project_shortname = "default"; + let project_cache_directory_path_str = cache_directory.unwrap_or_else(|| { panic!("Cache directory must be set on the command line (eg cargo run -- 2000 path/to/cache/dir)") } ); println!("Using {} as cache directory", project_cache_directory_path_str );