Skip to content

Commit

Permalink
Replace civet with conduit-hyper
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgeibel committed Jul 18, 2018
1 parent 50cc1d4 commit 610b0f6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 32 deletions.
35 changes: 16 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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"

[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
13 changes: 5 additions & 8 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#![deny(warnings)]

extern crate cargo_registry;
extern crate civet;
extern crate conduit_hyper;
extern crate env_logger;
extern crate git2;

use cargo_registry::{env, Env};
use civet::Server;
use conduit_hyper::Service;
use std::env;
use std::fs::{self, File};
use std::sync::mpsc::channel;
use std::sync::Arc;

fn main() {
Expand Down Expand Up @@ -66,9 +65,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 @@ -79,6 +77,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);
}

0 comments on commit 610b0f6

Please sign in to comment.