Skip to content

Commit

Permalink
Spawn init_metrics on CORE to run on tokio runtime and avoid panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
artemii235 committed Dec 12, 2020
1 parent 0eb3342 commit f66fcc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 6 additions & 1 deletion mm2src/lp_native_dex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,12 @@ pub async fn lp_init(mypubport: u16, ctx: MmArc) -> Result<(), String> {
let ctx_id = try_s!(ctx.ffi_handle());

spawn_rpc(ctx_id);

let ctxʹ = ctx.clone();
spawn(async move {
if let Err(err) = ctxʹ.init_metrics() {
log!("Warning: couldn't initialize metrics system: "(err));
}
});
// In the mobile version we might depend on `lp_init` staying around until the context stops.
loop {
if ctx.is_stopping() {
Expand Down
3 changes: 0 additions & 3 deletions mm2src/mm2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ pub fn lp_main(conf: Json, ctx_cb: &dyn Fn(u32)) -> Result<(), String> {
let netid = conf["netid"].as_u64().unwrap_or(0) as u16;
let (_, pubport, _) = try_s!(lp_ports(netid));
let ctx = MmCtxBuilder::new().with_conf(conf).into_mm_arc();
if let Err(err) = ctx.init_metrics() {
log!("Warning: couldn't initialize metricx system: "(err));
}
ctx_cb(try_s!(ctx.ffi_handle()));
try_s!(block_on(lp_init(pubport, ctx)));
Ok(())
Expand Down

0 comments on commit f66fcc0

Please sign in to comment.