Skip to content

Commit

Permalink
download web files, release workflow adds web static files
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed May 5, 2021
1 parent d076c2e commit b8f79ae
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
tag: ${{ github.ref }}
overwrite: true
- name: Web
run: zip -r public.zip ol/cli/web-monitor
run: zip -r web-monitor.zip ol/cli/web-monitor
- name: Upload Web Files
uses: svenstaro/upload-release-action@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ download: web-files
done

web-files:
curl -L --progress-bar --create-dirs -o ${DATA_PATH}/web-monitor/public.zip https://github.com/OLSF/libra/releases/download/v4.3.0-rc.0/public.zip
curl -L --progress-bar --create-dirs -o ${DATA_PATH}/web-monitor/public.zip https://github.com/OLSF/libra/releases/latest/download/public.zip
unzip ${DATA_PATH}/web-monitor/public.zip

download-release:
Expand Down
16 changes: 12 additions & 4 deletions ol/cli/src/commands/serve_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
use crate::{entrypoint, node::{client, node::Node}, prelude::app_config, server};
use abscissa_core::{Command, Options, Runnable};
#[derive(Command, Debug, Options)]
pub struct ServeCmd {}
pub struct ServeCmd {
/// Update the web files
#[options(no_short, help = "update web files for server")]
update: bool
}

impl Runnable for ServeCmd {
/// Start the application.
fn run(&self) {
let args = entrypoint::get_args();
let cfg = app_config().clone();
let client = client::pick_client(args.swarm_path, &cfg).unwrap().0;
let node = Node::new(client, cfg);
server::start_server(node);
if self.update {
server::update_web(&cfg.workspace.node_home);
} else {
let client = client::pick_client(args.swarm_path, &cfg).unwrap().0;
let node = Node::new(client, cfg);
server::start_server(node);
}
}
}
17 changes: 16 additions & 1 deletion ol/cli/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! `server` web monitor http server
use futures::StreamExt;
use serde_json::json;
use std::{convert::Infallible, fs, path::PathBuf, thread, time::Duration};
use std::{convert::Infallible, fs, path::PathBuf, process::Command, thread, time::Duration};
use tokio::time::interval;
use warp::{sse::ServerSentEvent, Filter};
use ol_types::config::IS_PROD;
Expand Down Expand Up @@ -68,3 +68,18 @@ pub async fn start_server(node: Node) {
.run(([0, 0, 0, 0], 3030))
.await;
}

/// Fetch updated static web files from release, for web-monitor.
pub fn update_web(home_path: &PathBuf) {
let zip_path = home_path.join("web-monitor.zip").to_str().unwrap().to_owned();
let args = vec!["-L", "--progress-bar", "--create-dirs", "-o", &zip_path, "https://github.com/OLSF/libra/releases/latest/download/public.zip"];

Command::new("curl")
.args(args.as_slice())
.output()
.expect("failed to download web files");
Command::new("unzip")
.arg(&zip_path)
.output()
.expect("failed to unzip web files");
}

0 comments on commit b8f79ae

Please sign in to comment.