|
|
@@ -1,18 +1,18 @@
|
|
|
use std::ops::Div;
|
|
|
use std::sync::Arc;
|
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
|
-use serde::{Deserialize, Serialize};
|
|
|
+use serde::{Serialize};
|
|
|
use strategy::quant::Quant;
|
|
|
use actix_web::{web, App, HttpResponse, HttpServer, Responder, post, get};
|
|
|
use rust_decimal::Decimal;
|
|
|
use tokio::sync::Mutex;
|
|
|
-use tracing::{debug, info};
|
|
|
+use tracing::{info};
|
|
|
|
|
|
|
|
|
-#[derive(Deserialize, Debug)]
|
|
|
-struct InputData {
|
|
|
- stop: bool,
|
|
|
-}
|
|
|
+// #[derive(Deserialize, Debug)]
|
|
|
+// struct InputData {
|
|
|
+// stop: i64,
|
|
|
+// }
|
|
|
|
|
|
#[derive(Serialize, Clone)]
|
|
|
struct AccountInfo {
|
|
|
@@ -72,15 +72,9 @@ async fn get_account(arcs: web::Data<Arcs>) -> impl Responder {
|
|
|
|
|
|
// 句柄 POST 请求
|
|
|
#[post("/exit")]
|
|
|
-async fn on_change(arcs: web::Data<Arcs>, input: web::Json<InputData>) -> impl Responder {
|
|
|
- debug!(?input);
|
|
|
-
|
|
|
- if input.stop {
|
|
|
- arcs.running.store(false, Ordering::Relaxed);
|
|
|
- HttpResponse::Ok().body(format!("程序已收到退出信号,将在10秒内退出。"))
|
|
|
- } else {
|
|
|
- HttpResponse::ServiceUnavailable().body(format!("程序没有收到正确的信号:{:?}。", input))
|
|
|
- }
|
|
|
+async fn on_change(arcs: web::Data<Arcs>) -> impl Responder {
|
|
|
+ arcs.running.store(false, Ordering::Relaxed);
|
|
|
+ HttpResponse::Ok().body(format!("程序已收到退出信号,将在5秒内退出。"))
|
|
|
}
|
|
|
|
|
|
pub fn run_server(port: u32, running: Arc<AtomicBool>, quant_arc: Arc<Mutex<Quant>>) {
|