Skip to content

Commit

Permalink
rewrite CommandServer with MIO
Browse files Browse the repository at this point in the history
The multi-threaded, event-based architecture was too complicated and
prevented introducing protobuf channels.
The new CommandServer functions on the same principle as the proxy
logic of Sōzu: listen to events with Mio in an event loop, dispatch
the events accordingly by creating WorkerSessions, ClientSessions.
This new CommandServer allows to create Tasks, that can scatter
requests to all workers, gather their responses as the event loop goes,
and invoke the task finish() when all responses are gathered.

A worker whose unix socket is disconnected will be killed,
and automatically restarted if configurated to. Conversely, if the
main process dies, the orphaned workers will perform a hard stop.

Sōzu channels used everywhere for communication with workers and
clients.

Automatic counting and respawning of workers, at each tick

implement soft stop and hard stop

improve CLI:
- disable logging in CLI when displaying JSON
- sort list of workers when displaying status

error handling with thiserror

remove obsolete documentation on managing workers
remove unused dependencies: smol, futures, futures-lite, anyhow

Co-Authored-By: Emmanuel BOSQUET <[email protected]>
  • Loading branch information
Wonshtrum and Keksoj committed Jan 30, 2024
1 parent d7b23c9 commit 7fe950a
Show file tree
Hide file tree
Showing 30 changed files with 3,238 additions and 3,778 deletions.
455 changes: 21 additions & 434 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 4 additions & 15 deletions bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,12 @@ authors = [
"Florentin Dubois <[email protected]>",
]
categories = ["network-programming"]
edition="2021"
edition = "2021"
rust-version = "1.70.0"
include = [
"README.md",
"Cargo.toml",
"src/**/*",
]
include = ["README.md", "Cargo.toml", "src/**/*"]

[dependencies]
anyhow = "^1.0.79"
async-dup = "^1.2.4"
async-io = "^1.13.0"
clap = { version = "^4.4.18", features = ["derive"] }
futures = "^0.3.30"
futures-lite = "^1.13.0"
hex = "^0.4.3"
jemallocator = { version = "^0.5.4", optional = true }
libc = "^0.2.152"
log = "^0.4.20"
Expand All @@ -40,13 +30,12 @@ paw = "^1.0.0"
serde = { version = "^1.0.195", features = ["derive"] }
serde_json = "^1.0.111"
time = "^0.3.29"
regex = "^1.10.3"
smol = "^1.3.0"
tempfile = "^3.9.0"
termion = "^3.0.0"

sozu-command-lib = { path = "../command", version = "^0.15.19" }
sozu-lib = { path = "../lib", version = "^0.15.19" }
thiserror = "^1.0.49"


[target.'cfg(target_os="linux")'.dependencies]
num_cpus = "^1.16.0"
Expand Down
5 changes: 4 additions & 1 deletion bin/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ pub enum SubCmd {
#[clap(long = "hard", help = "do not wait for connections to finish")]
hard: bool,
},
#[clap(name = "upgrade", about = "upgrade the proxy")]
#[clap(
name = "upgrade",
about = "upgrade the main process OR a specific worker. Specify a longer timeout."
)]
Upgrade {
#[clap(long = "worker", help = "upgrade a specific worker")]
worker: Option<u32>,
Expand Down
Loading

0 comments on commit 7fe950a

Please sign in to comment.