mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
appmgr: minor fixes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use embassy::context::{EitherContext, RpcContext};
|
||||
@@ -14,9 +15,8 @@ fn status_fn(_: i32) -> StatusCode {
|
||||
StatusCode::OK
|
||||
}
|
||||
|
||||
async fn inner_main() -> Result<(), Error> {
|
||||
simple_logging::log_to_stderr(log::LevelFilter::Info);
|
||||
let rpc_ctx = RpcContext::init().await?;
|
||||
async fn inner_main(cfg_path: Option<&str>) -> Result<(), Error> {
|
||||
let rpc_ctx = RpcContext::init(cfg_path).await?;
|
||||
if !rpc_ctx.db.exists(&<JsonPointer>::default()).await? {
|
||||
rpc_ctx
|
||||
.db
|
||||
@@ -24,7 +24,12 @@ async fn inner_main() -> Result<(), Error> {
|
||||
.await?;
|
||||
}
|
||||
let ctx = EitherContext::Rpc(rpc_ctx.clone());
|
||||
let server = rpc_server!(embassy::main_api, ctx, status_fn);
|
||||
let server = rpc_server!({
|
||||
command: embassy::main_api,
|
||||
context: ctx,
|
||||
status: status_fn,
|
||||
|
||||
});
|
||||
let status_ctx = rpc_ctx.clone();
|
||||
let status_daemon = daemon(
|
||||
move || {
|
||||
@@ -70,8 +75,32 @@ async fn inner_main() -> Result<(), Error> {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let matches = clap::App::new("embassyd")
|
||||
.arg(
|
||||
clap::Arg::with_name("config")
|
||||
.short("c")
|
||||
.long("config")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
clap::Arg::with_name("verbosity")
|
||||
.short("v")
|
||||
.multiple(true)
|
||||
.takes_value(false),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
simple_logging::log_to_stderr(match matches.occurrences_of("verbosity") {
|
||||
0 => log::LevelFilter::Off,
|
||||
1 => log::LevelFilter::Error,
|
||||
2 => log::LevelFilter::Warn,
|
||||
3 => log::LevelFilter::Info,
|
||||
4 => log::LevelFilter::Debug,
|
||||
_ => log::LevelFilter::Trace,
|
||||
});
|
||||
let cfg_path = matches.value_of("config");
|
||||
let rt = tokio::runtime::Runtime::new().expect("failed to initialize runtime");
|
||||
match rt.block_on(inner_main()) {
|
||||
match rt.block_on(inner_main(cfg_path)) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
drop(rt);
|
||||
|
||||
Reference in New Issue
Block a user