1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Rebuilding on every save without dropping the listening socket.
//!
//! Two tools outside this workspace, then the example:
//!
//! ```text
//! cargo install cargo-watch systemfd
//! systemfd --no-pid -s http::3000 -- cargo watch -x \
//! 'run -p kynos --example auto_reload --no-default-features \
//! --features openapi31,macros,server,http1'
//! ```
//!
//! `systemfd` opens the socket once and hands it to each rebuilt process;
//! `cargo watch` restarts that process on every save. Plain
//! `cargo run --example auto_reload` also works — it binds the port itself and
//! simply has nothing to inherit.
//!
//! Three things are worth noticing:
//!
//! * **Kynos owns no reload machinery, and should not.** Watching files and
//! restarting processes is a build tool's job, and a framework that
//! reimplemented it would be a worse `cargo watch` welded to a web server.
//! The framework's entire obligation is the one below: accept a socket it did
//! not open.
//! * **The socket is what survives, and that is the point.** Without
//! inheritance the port is unbound for the length of a rebuild, so a request
//! arriving in that window is refused rather than queued and every open
//! connection is severed. With it, the kernel keeps accepting into the
//! listener's backlog while nothing is listening, and the new process picks up
//! where the old one stopped.
//! * **An inherited listener is already bound, so nothing re-resolves it.**
//! [`Server::listener`] takes it as-is; [`Server::bind`] is the path that
//! resolves a name and binds. Mixing them is allowed and is exactly what the
//! fallback below relies on — a server with neither is
//! [`ServerError::NoListeners`], never a server that silently serves nothing.
//!
//! Graceful shutdown is not decoration here. `cargo watch` sends a termination
//! signal before it rebuilds, so without a drain every restart would cut off
//! whatever was in flight — which is the failure the inherited socket was meant
//! to avoid in the first place.
//!
//! [`Server::listener`]: kynos::server::Server::listener
//! [`Server::bind`]: kynos::server::Server::bind
//! [`ServerError::NoListeners`]: kynos::server::error::ServerError::NoListeners
use Ipv4Addr;
use ;
/// Reports the running build.
///
/// Edit the string, save, and watch the response change without the port ever
/// going away.
async
async