mirror of
https://github.com/Bluemangoo/sekai-unpacker.git
synced 2026-05-06 20:44:47 +08:00
fix multiple server
This commit is contained in:
parent
3d5ca3b1f8
commit
c07e5b835e
@ -143,7 +143,11 @@ async fn main() -> anyhow::Result<()> {
|
||||
let liveness_tx = liveness_tx.clone();
|
||||
join_set.spawn(async move {
|
||||
let _guard = liveness_tx;
|
||||
let mut inner_set = JoinSet::new();
|
||||
loop {
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
let client = sender.recv();
|
||||
if client.is_none() {
|
||||
continue;
|
||||
@ -152,18 +156,27 @@ async fn main() -> anyhow::Result<()> {
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
let semaphore = semaphore.clone();
|
||||
let cancel_token = cancel_token.clone();
|
||||
let profile = profile.clone();
|
||||
inner_set.spawn(async move {
|
||||
loop {
|
||||
if client.get_client().await.is_err() {
|
||||
break;
|
||||
return;
|
||||
}
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
{
|
||||
let permit = semaphore.clone().acquire_owned().await.unwrap();
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
let result = run(client.clone(), profile.clone()).await;
|
||||
match result {
|
||||
Ok(true) => {
|
||||
post_task(profile.clone(), permit, cancel_token.clone()).await;
|
||||
post_task(profile.clone(), permit, cancel_token.clone())
|
||||
.await;
|
||||
}
|
||||
Err(error) => {
|
||||
error!("{}", error);
|
||||
@ -171,6 +184,9 @@ async fn main() -> anyhow::Result<()> {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
sleep(Duration::from_millis(100)).await; // let other client get semaphore
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -202,11 +218,16 @@ async fn main() -> anyhow::Result<()> {
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
{
|
||||
let permit = semaphore.clone().acquire_owned().await.unwrap();
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
}
|
||||
let result = run(client.clone(), profile.clone()).await;
|
||||
match result {
|
||||
Ok(true) => {
|
||||
post_task(profile.clone(), permit, cancel_token.clone()).await;
|
||||
post_task(profile.clone(), permit, cancel_token.clone())
|
||||
.await;
|
||||
}
|
||||
Err(error) => {
|
||||
error!("{}", error);
|
||||
@ -214,6 +235,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
sleep(Duration::from_millis(100)).await; // let other client get semaphore
|
||||
}
|
||||
}
|
||||
if cancel_token.is_cancelled() {
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user