Skip to content

Commit a0b36cd

Browse files
committed
Auto merge of #1633 - sgrif:sg-revert-hyper, r=jtgeibel
Revert "Auto merge of #1618 - jtgeibel:conduit-hyper-round2, r=sgrif" This reverts commit 69368a6, reversing changes made to 6fa8ad3. When deploying this change, we saw response times nearly triple, and our CPU usage went through the roof. Additionally, this did not appear to fix the memory issues we were hoping to address by removing civet. /cc @jtgeibel
2 parents 69368a6 + d19d2d4 commit a0b36cd

File tree

7 files changed

+51
-26
lines changed

7 files changed

+51
-26
lines changed

Cargo.lock

Lines changed: 27 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ rustdoc-args = [
2929

3030
[dependencies]
3131
cargo-registry-s3 = { path = "src/s3", version = "0.2.0" }
32+
old_semver = { path = "src/old_semver", version = "0.1.0" }
3233
rand = "0.3"
3334
git2 = "0.6.4"
3435
flate2 = "1.0"
@@ -76,7 +77,7 @@ conduit-middleware = "0.8"
7677
conduit-router = "0.8"
7778
conduit-static = "0.8"
7879
conduit-git-http-backend = "0.8"
79-
conduit-hyper = "0.1.3"
80+
civet = "0.9"
8081

8182
[dev-dependencies]
8283
conduit-test = "0.8"

docs/BACKEND.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ The server does the following things:
1212
3. Reads values from environment variables to configure a new instance of `cargo_registry::App`
1313
4. Adds middleware to the app by calling `cargo_registry::middleware`
1414
5. Syncs the categories defined in *src/categories.toml* with the categories in the database
15-
6. Starts a [hyper] server that uses the `cargo_registry::App` instance
15+
6. Starts a [civet][] `Server` that uses the `cargo_registry::App` instance
1616
7. Tells Nginx on Heroku that the application is ready to receive requests, if running on Heroku
17-
8. Blocks forever (or until the process is killed)
17+
8. Blocks forever (or until the process is killed) waiting to receive messages on a channel that no
18+
messages are ever sent to, in order to outive the civet `Server` threads
1819

19-
[hyper]: https://crates.io/crates/hyper
20+
[civet]: https://crates.io/crates/civet
2021

2122
## Routes
2223

src/bin/server.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use jemalloc_ctl;
55
use std::{
66
env,
77
fs::{self, File},
8-
sync::Arc,
8+
sync::{mpsc::channel, Arc},
99
};
1010

11-
use conduit_hyper::Service;
11+
use civet::Server;
1212

1313
fn main() {
1414
let _ = jemalloc_ctl::set_background_thread(true);
@@ -66,8 +66,9 @@ fn main() {
6666
} else {
6767
50
6868
};
69-
let addr = ([127, 0, 0, 1], port).into();
70-
let server = Service::new(app, threads);
69+
let mut cfg = civet::Config::new();
70+
cfg.port(port).threads(threads).keep_alive(true);
71+
let _a = Server::start(cfg, app);
7172

7273
println!("listening on port {}", port);
7374

@@ -78,5 +79,6 @@ fn main() {
7879
}
7980

8081
// TODO: handle a graceful shutdown by just waiting for a SIG{INT,TERM}
81-
server.run(addr);
82+
let (_tx, rx) = channel::<()>();
83+
rx.recv().unwrap();
8284
}

src/old_semver/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "old_semver"
3+
version = "0.1.0"
4+
authors = ["Sean Griffin <[email protected]>"]
5+
6+
[dependencies]
7+
semver = "0.5.0"

src/old_semver/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// We need semver 0.5.0 for conduit, but we want to use newer versions.
2+
/// This is a silly workaround.
3+
pub extern crate semver;

src/util/request_proxy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{io::Read, net::SocketAddr};
22

33
use conduit::Request;
4-
use conduit_hyper::semver;
4+
use old_semver::semver;
55

66
// Can't derive Debug because of Request.
77
#[allow(missing_debug_implementations)]

0 commit comments

Comments
 (0)