Skip to content

Revert "Auto merge of #1618 - jtgeibel:conduit-hyper-round2, r=sgrif" #1633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rustdoc-args = [

[dependencies]
cargo-registry-s3 = { path = "src/s3", version = "0.2.0" }
old_semver = { path = "src/old_semver", version = "0.1.0" }
rand = "0.3"
git2 = "0.6.4"
flate2 = "1.0"
Expand Down Expand Up @@ -76,7 +77,7 @@ conduit-middleware = "0.8"
conduit-router = "0.8"
conduit-static = "0.8"
conduit-git-http-backend = "0.8"
conduit-hyper = "0.1.3"
civet = "0.9"

[dev-dependencies]
conduit-test = "0.8"
Expand Down
7 changes: 4 additions & 3 deletions docs/BACKEND.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ The server does the following things:
3. Reads values from environment variables to configure a new instance of `cargo_registry::App`
4. Adds middleware to the app by calling `cargo_registry::middleware`
5. Syncs the categories defined in *src/categories.toml* with the categories in the database
6. Starts a [hyper] server that uses the `cargo_registry::App` instance
6. Starts a [civet][] `Server` that uses the `cargo_registry::App` instance
7. Tells Nginx on Heroku that the application is ready to receive requests, if running on Heroku
8. Blocks forever (or until the process is killed)
8. Blocks forever (or until the process is killed) waiting to receive messages on a channel that no
messages are ever sent to, in order to outive the civet `Server` threads

[hyper]: https://crates.io/crates/hyper
[civet]: https://crates.io/crates/civet

## Routes

Expand Down
12 changes: 7 additions & 5 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use jemalloc_ctl;
use std::{
env,
fs::{self, File},
sync::Arc,
sync::{mpsc::channel, Arc},
};

use conduit_hyper::Service;
use civet::Server;

fn main() {
let _ = jemalloc_ctl::set_background_thread(true);
Expand Down Expand Up @@ -66,8 +66,9 @@ fn main() {
} else {
50
};
let addr = ([127, 0, 0, 1], port).into();
let server = Service::new(app, threads);
let mut cfg = civet::Config::new();
cfg.port(port).threads(threads).keep_alive(true);
let _a = Server::start(cfg, app);

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

Expand All @@ -78,5 +79,6 @@ fn main() {
}

// TODO: handle a graceful shutdown by just waiting for a SIG{INT,TERM}
server.run(addr);
let (_tx, rx) = channel::<()>();
rx.recv().unwrap();
}
7 changes: 7 additions & 0 deletions src/old_semver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "old_semver"
version = "0.1.0"
authors = ["Sean Griffin <[email protected]>"]

[dependencies]
semver = "0.5.0"
3 changes: 3 additions & 0 deletions src/old_semver/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// We need semver 0.5.0 for conduit, but we want to use newer versions.
/// This is a silly workaround.
pub extern crate semver;
2 changes: 1 addition & 1 deletion src/util/request_proxy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{io::Read, net::SocketAddr};

use conduit::Request;
use conduit_hyper::semver;
use old_semver::semver;

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