mingyang91 commited on
Commit
a1dd3ea
1 Parent(s): dc74add

handle ctrl_c signal

Browse files
Files changed (3) hide show
  1. CUDA11.4.Dockerfile +3 -5
  2. Cargo.toml +1 -1
  3. src/main.rs +7 -1
CUDA11.4.Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
- FROM nvidia/cuda:11.4.3-devel-ubuntu20.04 as chef
2
- RUN apt-get update && apt-get install -y curl
3
  RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y
4
  ENV PATH=/root/.cargo/bin:$PATH
5
  RUN cargo install cargo-chef
@@ -10,14 +10,12 @@ COPY . .
10
  RUN cargo chef prepare --recipe-path recipe.json
11
 
12
  FROM chef as builder
13
- ENV DEBIAN_FRONTEND=noninteractive
14
- RUN apt-get update && apt-get install -y cmake g++ libclang-dev libssl-dev pkg-config python3-dev
15
  COPY --from=planner /app/recipe.json recipe.json
16
  RUN cargo chef cook --release --recipe-path recipe.json
17
  COPY . .
18
  RUN cargo build --release
19
 
20
- FROM nvidia/cuda:11.4.3-runtime-ubuntu20.04 as runtime
21
 
22
  RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
23
  WORKDIR /app
 
1
+ FROM nvidia/cuda:11.4.3-cudnn8-devel-ubuntu20.04 as chef
2
+ RUN apt-get update && apt-get install -y cmake g++ libclang-dev libssl-dev pkg-config python3-dev curl
3
  RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y
4
  ENV PATH=/root/.cargo/bin:$PATH
5
  RUN cargo install cargo-chef
 
10
  RUN cargo chef prepare --recipe-path recipe.json
11
 
12
  FROM chef as builder
 
 
13
  COPY --from=planner /app/recipe.json recipe.json
14
  RUN cargo chef cook --release --recipe-path recipe.json
15
  COPY . .
16
  RUN cargo build --release
17
 
18
+ FROM nvidia/cuda:11.4.3-cudnn8-runtime-ubuntu20.04 as runtime
19
 
20
  RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
21
  WORKDIR /app
Cargo.toml CHANGED
@@ -16,7 +16,7 @@ once_cell = "1.18"
16
  serde = { version = "1.0", features = ["derive"] }
17
  serde_json = "1.0"
18
  serde_yaml = "0.9"
19
- tokio = { version = "1.33", features = ["macros", "rt-multi-thread", "sync"] }
20
  tokio-stream = "0.1"
21
  tracing = "0.1"
22
  tracing-subscriber = { version = "0.3", features = ["env-filter"] }
 
16
  serde = { version = "1.0", features = ["derive"] }
17
  serde_json = "1.0"
18
  serde_yaml = "0.9"
19
+ tokio = { version = "1.33", features = ["macros", "rt-multi-thread", "sync", "signal"] }
20
  tokio-stream = "0.1"
21
  tracing = "0.1"
22
  tracing-subscriber = { version = "0.3", features = ["env-filter"] }
src/main.rs CHANGED
@@ -70,7 +70,13 @@ async fn main() -> Result<(), std::io::Error> {
70
  let listener = TcpListener::bind(addr);
71
  let server = Server::new(listener);
72
 
73
- server.run(app).await
 
 
 
 
 
 
74
  }
75
 
76
  #[derive(Deserialize, Debug)]
 
70
  let listener = TcpListener::bind(addr);
71
  let server = Server::new(listener);
72
 
73
+ select! {
74
+ res = server.run(app) => res,
75
+ _ = tokio::signal::ctrl_c() => {
76
+ tracing::info!("Shutting down");
77
+ Ok(())
78
+ },
79
+ }
80
  }
81
 
82
  #[derive(Deserialize, Debug)]