这是indexloc提供的服务,不要输入任何密码
Skip to content
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
75 changes: 72 additions & 3 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,29 @@ ifeq ($(shell cargo show --json bayard | jq -r '.versions[].num' | grep $(BAYARD
endif

docker-build:
ifeq ($(shell curl 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_VERSION)),)
ifeq ($(shell curl -s 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_VERSION)),)
docker build --tag=bayardsearch/bayard:latest --file=bayard.dockerfile --build-arg="BAYARD_VERSION=$(BAYARD_VERSION)" .
docker tag bayardsearch/bayard:latest bayardsearch/bayard:$(BAYARD_VERSION)
endif
ifeq ($(shell curl 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-rest/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_REST_VERSION)),)
ifeq ($(shell curl -s 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-rest/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_REST_VERSION)),)
docker build --tag=bayardsearch/bayard-rest:latest --file=bayard-rest.dockerfile --build-arg="BAYARD_REST_VERSION=$(BAYARD_REST_VERSION)" .
docker tag bayardsearch/bayard-rest:latest bayardsearch/bayard-rest:$(BAYARD_REST_VERSION)
endif
ifeq ($(shell curl 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-cli/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_CLI_VERSION)),)
ifeq ($(shell curl -s 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-cli/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_CLI_VERSION)),)
docker build --tag=bayardsearch/bayard-cli:latest --file=bayard-cli.dockerfile --build-arg="BAYARD_CLI_VERSION=$(BAYARD_CLI_VERSION)" .
docker tag bayardsearch/bayard-cli:latest bayardsearch/bayard-cli:$(BAYARD_CLI_VERSION)
endif

docker-push:
ifeq ($(shell curl 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_VERSION)),)
ifeq ($(shell curl -s 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_VERSION)),)
docker push bayardsearch/bayard:latest
docker push bayardsearch/bayard:$(BAYARD_VERSION)
endif
ifeq ($(shell curl 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-rest/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_REST_VERSION)),)
ifeq ($(shell curl -s 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-rest/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_REST_VERSION)),)
docker push bayardsearch/bayard-rest:latest
docker push bayardsearch/bayard-rest:$(BAYARD_REST_VERSION)
endif
ifeq ($(shell curl 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-cli/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_CLI_VERSION)),)
ifeq ($(shell curl -s 'https://registry.hub.docker.com/v2/repositories/bayardsearch/bayard-cli/tags' | jq -r '."results"[]["name"]' | grep $(BAYARD_CLI_VERSION)),)
docker push bayardsearch/bayard-cli:latest
docker push bayardsearch/bayard-cli:$(BAYARD_CLI_VERSION)
endif
Expand Down
1 change: 1 addition & 0 deletions bayard-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ license = "MIT"
crossbeam-channel = "0.4.2"
ctrlc = { version = "3.1.4", features = ["termination"] }
env_logger = "0.7.1"
tokio = { version = "0.2.21", features = ["signal"] }
7 changes: 7 additions & 0 deletions bayard-common/src/signal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crossbeam_channel::{bounded, Receiver};
use ctrlc;
use tokio;

pub fn sigterm_channel() -> Result<Receiver<()>, ctrlc::Error> {
let (sender, receiver) = bounded(100);
Expand All @@ -10,3 +11,9 @@ pub fn sigterm_channel() -> Result<Receiver<()>, ctrlc::Error> {

Ok(receiver)
}

pub async fn shutdown_signal() {
tokio::signal::ctrl_c()
.await
.expect("failed to install CTRL+C signal handler");
}
3 changes: 1 addition & 2 deletions bayard-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ categories = ["database"]
license = "MIT"

[dependencies]
actix-server = "1.0.2"
actix-web = "2.0.0"
async-std = "1.5.0"
bincode = "1.2.1"
cang-jie = "0.8.0"
futures = "0.1.29"
grpcio = { version = "0.4.7", features = [ "secure" ] }
hyper = "0.13.5"
jieba-rs = "0.5.0"
lazy_static = "1.4.0"
lindera-tantivy = "0.1.1"
Expand Down
28 changes: 18 additions & 10 deletions bayard-server/src/metric/handler.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
use actix_web::{get, Error, HttpResponse};
use hyper::{Body, Method, Request, Response, StatusCode};
use prometheus::{Encoder, TextEncoder};

#[get("/metrics")]
pub async fn metrics() -> Result<HttpResponse, Error> {
let metric_families = prometheus::gather();
let mut buffer = Vec::<u8>::new();
let encoder = TextEncoder::new();
encoder.encode(&metric_families, &mut buffer).unwrap();
let metrics_text = String::from_utf8(buffer.clone()).unwrap();
pub async fn handle(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
let mut response = Response::new(Body::empty());
match (req.method(), req.uri().path()) {
(&Method::GET, "/metrics") => {
let metric_families = prometheus::gather();
let mut buffer = Vec::<u8>::new();
let encoder = TextEncoder::new();
encoder.encode(&metric_families, &mut buffer).unwrap();
let metrics_text = String::from_utf8(buffer.clone()).unwrap();

let res = HttpResponse::Ok().body(metrics_text);
Ok(res)
*response.status_mut() = StatusCode::OK;
*response.body_mut() = Body::from(metrics_text);
}
_ => {
*response.status_mut() = StatusCode::NOT_FOUND;
}
};
Ok(response)
}
1 change: 0 additions & 1 deletion bayard-server/src/metric/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pub mod handler;
pub mod server;
32 changes: 0 additions & 32 deletions bayard-server/src/metric/server.rs

This file was deleted.

3 changes: 2 additions & 1 deletion bayard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ name = "bayard"
path = "src/main.rs"

[dependencies]
actix-rt = "1.1.1"
clap = "2.33.0"
crossbeam-channel = "0.4.2"
futures = "0.1.29"
grpcio = { version = "0.4.7", features = ["secure"] }
hyper = "0.13.5"
log = "0.4.8"
num_cpus = "1.13.0"
raft = "0.4.3"
serde_json = "1.0.51"
tokio = { version = "0.2.21", features = ["macros"] }

bayard-proto = "0.8.0"

Expand Down
Loading