Skip to content

Commit ca435b2

Browse files
committed
prepare actix-server release 2.0.0-beta.6
1 parent 9fa8d7f commit ca435b2

File tree

8 files changed

+63
-39
lines changed

8 files changed

+63
-39
lines changed

actix-server/CHANGES.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
# Changes
22

33
## Unreleased - 2021-xx-xx
4-
* Remove `config` module. `ServiceConfig`, `ServiceRuntime` public types are removed due to this change. [#349]
5-
* Remove `ServerBuilder::configure` [#349]
4+
5+
6+
## 2.0.0-beta.6 - 2021-10-11
67
* Add `io-uring` feature for enabling async file I/O on linux. [#374]
7-
* Server no long listens to SIGHUP signal.
8-
It actually did not take any action when receiving SIGHUP, the only thing SIGHUP did was to stop
9-
the Server from receiving any future signal, because the `Signals` future stops on the first
10-
signal received [#389]
8+
* Server no long listens to `SIGHUP` signal. Previously, the received was not used but did block
9+
subsequent exit signals from working. [#389]
10+
* Remove `config` module. `ServiceConfig`, `ServiceRuntime` public types are removed due to
11+
this change. [#349]
12+
* Remove `ServerBuilder::configure` [#349]
1113

1214
[#374]: https://github.com/actix/actix-net/pull/374
1315
[#349]: https://github.com/actix/actix-net/pull/349
1416
[#389]: https://github.com/actix/actix-net/pull/389
1517

1618

1719
## 2.0.0-beta.5 - 2021-04-20
18-
* Server shutdown would notify all workers to exit regardless if shutdown is graceful.
19-
This would make all worker shutdown immediately in force shutdown case. [#333]
20-
20+
* Server shutdown notifies all workers to exit regardless if shutdown is graceful. This causes all
21+
workers to shutdown immediately in force shutdown case. [#333]
22+
2123
[#333]: https://github.com/actix/actix-net/pull/333
2224

2325

actix-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "actix-server"
3-
version = "2.0.0-beta.5"
3+
version = "2.0.0-beta.6"
44
authors = [
55
"Nikolay Kim <fafhrd91@gmail.com>",
66
"fakeshadow <24548779@qq.com>",

actix-server/src/builder.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,23 +312,25 @@ impl ServerBuilder {
312312
// Handle `SIGINT`, `SIGTERM`, `SIGQUIT` signals and stop actix system
313313
match sig {
314314
Signal::Int => {
315-
info!("SIGINT received, exiting");
315+
info!("SIGINT received, starting forced shutdown");
316316
self.exit = true;
317317
self.handle_cmd(ServerCommand::Stop {
318318
graceful: false,
319319
completion: None,
320320
})
321321
}
322+
322323
Signal::Term => {
323-
info!("SIGTERM received, stopping");
324+
info!("SIGTERM received, starting graceful shutdown");
324325
self.exit = true;
325326
self.handle_cmd(ServerCommand::Stop {
326327
graceful: true,
327328
completion: None,
328329
})
329330
}
331+
330332
Signal::Quit => {
331-
info!("SIGQUIT received, exiting");
333+
info!("SIGQUIT received, starting forced shutdown");
332334
self.exit = true;
333335
self.handle_cmd(ServerCommand::Stop {
334336
graceful: false,
@@ -359,12 +361,14 @@ impl ServerBuilder {
359361

360362
rt::spawn(async move {
361363
if graceful {
364+
// wait for all workers to shut down
362365
let _ = join_all(stop).await;
363366
}
364367

365368
if let Some(tx) = completion {
366369
let _ = tx.send(());
367370
}
371+
368372
for tx in notify {
369373
let _ = tx.send(());
370374
}

actix-server/src/server.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@ pub(crate) enum ServerCommand {
1515
Pause(oneshot::Sender<()>),
1616
Resume(oneshot::Sender<()>),
1717
Signal(Signal),
18-
/// Whether to try and shut down gracefully
1918
Stop {
19+
/// True if shut down should be graceful.
2020
graceful: bool,
2121
completion: Option<oneshot::Sender<()>>,
2222
},
2323
/// Notify of server stop
2424
Notify(oneshot::Sender<()>),
2525
}
2626

27+
/// Server handle.
28+
///
29+
/// # Shutdown Signals
30+
/// On UNIX systems, `SIGQUIT` will start a graceful shutdown and `SIGTERM` or `SIGINT` will start a
31+
/// forced shutdown. On Windows, a CTRL-C signal will start a forced shutdown.
32+
///
33+
/// A graceful shutdown will wait for all workers to stop first.
2734
#[derive(Debug)]
2835
pub struct Server(
2936
UnboundedSender<ServerCommand>,

actix-server/src/signals.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,33 @@ use std::task::{Context, Poll};
44

55
use crate::server::Server;
66

7-
/// Different types of process signals
7+
/// Types of process signals.
88
#[allow(dead_code)]
99
#[derive(PartialEq, Clone, Copy, Debug)]
1010
pub(crate) enum Signal {
11-
/// SIGINT
11+
/// `SIGINT`
1212
Int,
13-
/// SIGTERM
13+
14+
/// `SIGTERM`
1415
Term,
15-
/// SIGQUIT
16+
17+
/// `SIGQUIT`
1618
Quit,
1719
}
1820

21+
/// Process signal listener.
1922
pub(crate) struct Signals {
2023
srv: Server,
24+
2125
#[cfg(not(unix))]
2226
signals: futures_core::future::LocalBoxFuture<'static, std::io::Result<()>>,
27+
2328
#[cfg(unix)]
2429
signals: Vec<(Signal, actix_rt::signal::unix::Signal)>,
2530
}
2631

2732
impl Signals {
33+
/// Spawns a signal listening future that is able to send commands to the `Server`.
2834
pub(crate) fn start(srv: Server) {
2935
#[cfg(not(unix))]
3036
{
@@ -33,6 +39,7 @@ impl Signals {
3339
signals: Box::pin(actix_rt::signal::ctrl_c()),
3440
});
3541
}
42+
3643
#[cfg(unix)]
3744
{
3845
use actix_rt::signal::unix;
@@ -76,6 +83,7 @@ impl Future for Signals {
7683
}
7784
Poll::Pending => Poll::Pending,
7885
}
86+
7987
#[cfg(unix)]
8088
{
8189
for (sig, fut) in self.signals.iter_mut() {

actix-server/src/test_server.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ use actix_rt::{net::TcpStream, System};
55

66
use crate::{Server, ServerBuilder, ServiceFactory};
77

8-
/// The `TestServer` type.
8+
/// A testing server.
99
///
10-
/// `TestServer` is very simple test server that simplify process of writing
11-
/// integration tests for actix-net applications.
10+
/// `TestServer` is very simple test server that simplify process of writing integration tests for
11+
/// network applications.
1212
///
1313
/// # Examples
14-
///
1514
/// ```
1615
/// use actix_service::fn_service;
1716
/// use actix_server::TestServer;
@@ -39,7 +38,7 @@ pub struct TestServerRuntime {
3938
}
4039

4140
impl TestServer {
42-
/// Start new server with server builder
41+
/// Start new server with server builder.
4342
pub fn start<F>(mut factory: F) -> TestServerRuntime
4443
where
4544
F: FnMut(ServerBuilder) -> ServerBuilder + Send + 'static,
@@ -64,7 +63,7 @@ impl TestServer {
6463
}
6564
}
6665

67-
/// Start new test server with application factory
66+
/// Start new test server with application factory.
6867
pub fn with<F: ServiceFactory<TcpStream>>(factory: F) -> TestServerRuntime {
6968
let (tx, rx) = mpsc::channel();
7069

@@ -99,7 +98,7 @@ impl TestServer {
9998
}
10099
}
101100

102-
/// Get first available unused local address
101+
/// Get first available unused local address.
103102
pub fn unused_addr() -> net::SocketAddr {
104103
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
105104
let socket = mio::net::TcpSocket::new_v4().unwrap();
@@ -111,27 +110,27 @@ impl TestServer {
111110
}
112111

113112
impl TestServerRuntime {
114-
/// Test server host
113+
/// Test server host.
115114
pub fn host(&self) -> &str {
116115
&self.host
117116
}
118117

119-
/// Test server port
118+
/// Test server port.
120119
pub fn port(&self) -> u16 {
121120
self.port
122121
}
123122

124-
/// Get test server address
123+
/// Get test server address.
125124
pub fn addr(&self) -> net::SocketAddr {
126125
self.addr
127126
}
128127

129-
/// Stop http server
128+
/// Stop server.
130129
fn stop(&mut self) {
131130
self.system.stop();
132131
}
133132

134-
/// Connect to server, return tokio TcpStream
133+
/// Connect to server, returning a Tokio `TcpStream`.
135134
pub fn connect(&self) -> std::io::Result<TcpStream> {
136135
TcpStream::from_std(net::TcpStream::connect(self.addr)?)
137136
}

actix-server/src/worker.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,15 @@ struct Restart {
429429
fut: LocalBoxFuture<'static, Result<(usize, BoxedServerService), ()>>,
430430
}
431431

432-
// Shutdown keep states necessary for server shutdown:
433-
// Sleep for interval check the shutdown progress.
434-
// Instant for the start time of shutdown.
435-
// Sender for send back the shutdown outcome(force/grace) to StopCommand caller.
432+
/// State necessary for server shutdown.
436433
struct Shutdown {
434+
// Interval for checking the shutdown progress.
437435
timer: Pin<Box<Sleep>>,
436+
437+
/// Start time of shutdown.
438438
start_from: Instant,
439+
440+
/// Notify of the shutdown outcome (force/grace) to stop caller.
439441
tx: oneshot::Sender<bool>,
440442
}
441443

@@ -521,23 +523,25 @@ impl Future for ServerWorker {
521523
self.poll(cx)
522524
}
523525
WorkerState::Shutdown(ref mut shutdown) => {
524-
// Wait for 1 second.
526+
// wait for 1 second
525527
ready!(shutdown.timer.as_mut().poll(cx));
526528

527529
if this.counter.total() == 0 {
528-
// Graceful shutdown.
530+
// graceful shutdown
529531
if let WorkerState::Shutdown(shutdown) = mem::take(&mut this.state) {
530532
let _ = shutdown.tx.send(true);
531533
}
534+
532535
Poll::Ready(())
533536
} else if shutdown.start_from.elapsed() >= this.shutdown_timeout {
534-
// Timeout forceful shutdown.
537+
// timeout forceful shutdown
535538
if let WorkerState::Shutdown(shutdown) = mem::take(&mut this.state) {
536539
let _ = shutdown.tx.send(false);
537540
}
541+
538542
Poll::Ready(())
539543
} else {
540-
// Reset timer and wait for 1 second.
544+
// reset timer and wait for 1 second
541545
let time = Instant::now() + Duration::from_secs(1);
542546
shutdown.timer.as_mut().reset(time);
543547
shutdown.timer.as_mut().poll(cx)

actix-tls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ tokio-native-tls = { version = "0.3", optional = true }
6464

6565
[dev-dependencies]
6666
actix-rt = "2.2.0"
67-
actix-server = "2.0.0-beta.5"
67+
actix-server = "2.0.0-beta.6"
6868
bytes = "1"
6969
env_logger = "0.8"
7070
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }

0 commit comments

Comments
 (0)