Skip to content

Switch to conduit-hyper in place of civet #1618

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 22, 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: 16 additions & 27 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ 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 @@ -75,7 +74,7 @@ conduit-middleware = "0.8"
conduit-router = "0.8"
conduit-static = "0.8"
conduit-git-http-backend = "0.8"
civet = "0.9"
conduit-hyper = "0.1.3"

[dev-dependencies]
conduit-test = "0.8"
Expand Down
7 changes: 3 additions & 4 deletions docs/BACKEND.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ 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 [civet][] `Server` that uses the `cargo_registry::App` instance
6. Starts a [hyper] 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) waiting to receive messages on a channel that no
messages are ever sent to, in order to outive the civet `Server` threads
8. Blocks forever (or until the process is killed)

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

## Routes

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

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

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

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

Expand All @@ -76,6 +75,5 @@ fn main() {
}

// TODO: handle a graceful shutdown by just waiting for a SIG{INT,TERM}
let (_tx, rx) = channel::<()>();
rx.recv().unwrap();
server.run(addr);
}
7 changes: 0 additions & 7 deletions src/old_semver/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions src/old_semver/src/lib.rs

This file was deleted.

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 old_semver::semver;
use conduit_hyper::semver;

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