Create http api before adding the first torrent
This commit is contained in:
parent
6aa59ff83c
commit
f0d14ae92b
3 changed files with 13 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1380,7 +1380,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rqbit"
|
name = "rqbit"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rqbit"
|
name = "rqbit"
|
||||||
description = "A bittorent client"
|
description = "A bittorent client"
|
||||||
version = "1.1.1"
|
version = "1.1.2"
|
||||||
authors = ["Igor Katson <igor.katson@gmail.com>"]
|
authors = ["Igor Katson <igor.katson@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,16 @@ async fn async_main(opts: Opts, spawner: BlockingSpawner) -> anyhow::Result<()>
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let http_api = {
|
||||||
|
let http_api = HttpApi::new(session.clone());
|
||||||
|
spawn("HTTP API", {
|
||||||
|
let http_api_listen_addr = opts.http_api_listen_addr;
|
||||||
|
let http_api = http_api.clone();
|
||||||
|
async move { http_api.make_http_api_and_run(http_api_listen_addr).await }
|
||||||
|
});
|
||||||
|
http_api
|
||||||
|
};
|
||||||
|
|
||||||
let handle = match session
|
let handle = match session
|
||||||
.add_torrent(opts.torrent_path, Some(torrent_opts))
|
.add_torrent(opts.torrent_path, Some(torrent_opts))
|
||||||
.await
|
.await
|
||||||
|
|
@ -172,14 +182,7 @@ async fn async_main(opts: Opts, spawner: BlockingSpawner) -> anyhow::Result<()>
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
http_api.add_mgr(handle.clone());
|
||||||
let http_api = HttpApi::new(session.clone());
|
|
||||||
http_api.add_mgr(handle.clone());
|
|
||||||
spawn("HTTP API", {
|
|
||||||
let http_api_listen_addr = opts.http_api_listen_addr;
|
|
||||||
async move { http_api.make_http_api_and_run(http_api_listen_addr).await }
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
spawn("Stats printer", {
|
spawn("Stats printer", {
|
||||||
let session = session.clone();
|
let session = session.clone();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue