Skip to content

Commit

Permalink
json2capnp: Make the cache path argument mandatory
Browse files Browse the repository at this point in the history
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/<projectShortname> 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.
  • Loading branch information
tahini committed Nov 8, 2022
1 parent 61c7612 commit e9fb702
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
17 changes: 0 additions & 17 deletions services/json2capnp/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions services/json2capnp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 3 additions & 11 deletions services/json2capnp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*
*/

use dotenv;
use home;
use rouille::Request;
use rouille::Response;
use std::fs;
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit e9fb702

Please sign in to comment.