Skip to content

Commit

Permalink
Prepare v0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Caspar Oostendorp committed Feb 23, 2024
1 parent 3fb12ce commit 772dcb1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.7
0.1.8
2 changes: 1 addition & 1 deletion chart/keiko/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ version: 0.1.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.7"
appVersion: "0.1.8"
1 change: 1 addition & 0 deletions server/api/src/handlers/keiko/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub async fn store_manifest(Path(app_name): Path<String>, Extension(server_state

pub async fn get_manifest(Path(app_name): Path<String>, Extension(server_state): Extension<ServerState>) -> impl IntoResponse {
let path = format!("{}/{}.json", &server_state.manifest_base_dir, app_name);
println!("{}", path);
match fs::read_to_string(&path) {
Ok(content) => (StatusCode::OK, content),
Err(ref e) if e.kind() == ErrorKind::NotFound => (StatusCode::NOT_FOUND, "Not Found".into()),
Expand Down
10 changes: 6 additions & 4 deletions server/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ impl Config {
pub fn set_world_address(&mut self, world_address: String) {
self.world_address = world_address;
}
/**
* gets all katana args to run katana with
*/

pub fn get_storage_base_dir(&self) -> String {
format!("storage/{}", self.world_address)
}

pub fn get_katana_args(&self) -> Vec<String> {
let mut args = vec![];

Expand Down Expand Up @@ -281,7 +283,7 @@ impl Config {
* gets the server state
*/
pub fn server_state(&self) -> server_state::ServerState {
let manifest_base_dir = format!("storage/{}", self.world_address);
let manifest_base_dir = format!("{}/manifests", self.get_storage_base_dir());

server_state::ServerState {
json_rpc_client: self.json_rpc_client(),
Expand Down
17 changes: 10 additions & 7 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const KEIKO_ASSETS: &str = "static/keiko/assets";
const KEIKO_INDEX: &str = "static/keiko/index.html";
const KATANA_LOG: &str = "log/katana.log.json";
const TORII_LOG: &str = "log/torii.log";
const TORII_DB: &str = "torii.sqlite";
const CONFIG_MANIFEST: &str = "config/manifest.json";

#[tokio::main]
Expand All @@ -35,7 +36,7 @@ async fn main() {
.expect("Failed to build dashboard");
}

let katana = start_katana(config.get_katana_args()).await;
let katana = start_katana(&config).await;

// Get the world address from the manifest
let manifest_json: Value = serde_json::from_reader(
Expand All @@ -46,7 +47,7 @@ async fn main() {
config.set_world_address(world_address.to_string());

let rpc_url = "http://localhost:5050";
let torii = start_torii(world_address).await;
let torii = start_torii(&config).await;

// TODO Modify the Scarb.toml if needed with world address

Expand Down Expand Up @@ -79,7 +80,7 @@ async fn main() {
.nest_service("/assets", get_service(ServeDir::new(config.server.static_path.join("assets"))))
.fallback_service(get_service(ServeFile::new(config.server.static_path.join("index.html"))))
.layer(cors)
.layer(AddExtensionLayer::new(config));
.layer(AddExtensionLayer::new(config.server_state()));


let server = axum::Server::bind(&addr)
Expand All @@ -97,7 +98,9 @@ async fn main() {
torii.abort();
}

async fn start_katana(katana_args: Vec<String>) -> task::JoinHandle<()> {
async fn start_katana(config: &Config) -> task::JoinHandle<()> {
let katana_args = config.get_katana_args();

let result = task::spawn(async move {
let output = File::create(KATANA_LOG).expect("Failed to create file");

Expand All @@ -112,12 +115,12 @@ async fn start_katana(katana_args: Vec<String>) -> task::JoinHandle<()> {
result
}

async fn start_torii(world_address: String) -> task::JoinHandle<()> {
async fn start_torii(config: &Config) -> task::JoinHandle<()> {
let mut args: Vec<String> = vec![
"--world".to_string(),
world_address,
config.world_address.clone(),
"--database".to_string(),
format!("sqlite:///{}/storage/torii.sqlite", current_dir().unwrap().display()),
format!("{}/{}", config.get_storage_base_dir().clone(), TORII_DB),
];

let result = task::spawn(async move {
Expand Down

0 comments on commit 772dcb1

Please sign in to comment.