Skip to content

Commit

Permalink
Adding support for manifest loading to the wasmcloud binary (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
autodidaddict committed Mar 9, 2021
1 parent 387b8d2 commit 0cea03a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmcloud"
version = "0.15.2"
version = "0.15.3"
authors = ["wasmcloud Team"]
edition = "2018"
default-run = "wasmcloud"
Expand Down Expand Up @@ -75,8 +75,4 @@ members = [

[[bin]]
name = "wasmcloud"
path = "src/wasmcloud.rs"

[[bin]]
name = "wasmcloud-lite"
path = "src/wasmcloud-lite.rs"
path = "src/wasmcloud.rs"
5 changes: 0 additions & 5 deletions codegen.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions src/wasmcloud-lite.rs

This file was deleted.

21 changes: 19 additions & 2 deletions src/wasmcloud.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs::File;
use std::io::prelude::*;
use std::{fs::File, path::PathBuf};
use structopt::{clap::AppSettings, StructOpt};
use wasmcloud_host::{HostBuilder, Result};
use wasmcloud_host::{HostBuilder, HostManifest, Result};

#[macro_use]
extern crate log;
Expand Down Expand Up @@ -70,6 +70,10 @@ struct Cli {
/// Allows the use of HTTP registry connections to these registries
#[structopt(long = "allowed-insecure")]
allowed_insecure: Vec<String>,

/// Specifies a manifest file to apply to the host once started
#[structopt(long = "manifest", short = "m", parse(from_os_str))]
manifest: Option<PathBuf>,
}

#[actix_rt::main]
Expand All @@ -82,6 +86,13 @@ async fn main() -> Result<()> {
.format_module_path(false)
.try_init();

if let Some(ref pb) = cli.manifest {
if !pb.exists() {
error!("Specified manifest file {:?} could not be opened", pb);
return Err("Manifest file could not be opened.".into());
}
}

let nats_url = &format!("{}:{}", cli.rpc_host, cli.rpc_port);
let nc_rpc = nats_connection(nats_url, cli.rpc_jwt, cli.rpc_seed, cli.rpc_credsfile).await?;
let nc_control = nats_connection(
Expand Down Expand Up @@ -112,6 +123,12 @@ async fn main() -> Result<()> {
let host = host_builder.build();
match host.start().await {
Ok(_) => {
if let Some(pb) = cli.manifest {
if pb.exists() {
let hm = HostManifest::from_path(pb, true)?;
host.apply_manifest(hm).await?;
}
}
actix_rt::signal::ctrl_c().await.unwrap();
info!("Ctrl-C received, shutting down");
host.stop().await;
Expand Down

0 comments on commit 0cea03a

Please sign in to comment.