mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +02:00
better exit on error
Update meilisearch-core/src/database.rs Co-authored-by: Clément Renault <renault.cle@gmail.com> Update meilisearch-core/src/database.rs Co-authored-by: Clément Renault <renault.cle@gmail.com>
This commit is contained in:
parent
6f0b6933e6
commit
51d7c84e73
5 changed files with 15 additions and 17 deletions
|
@ -1,10 +1,10 @@
|
|||
use std::error::Error;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
use meilisearch_core::{Database, DatabaseOptions};
|
||||
use sha2::Digest;
|
||||
use sysinfo::Pid;
|
||||
use log::error;
|
||||
|
||||
use crate::index_update_callback;
|
||||
use crate::option::Opt;
|
||||
|
@ -56,7 +56,7 @@ impl ApiKeys {
|
|||
}
|
||||
|
||||
impl Data {
|
||||
pub fn new(opt: Opt) -> Data {
|
||||
pub fn new(opt: Opt) -> Result<Data, Box<dyn Error>> {
|
||||
let db_path = opt.db_path.clone();
|
||||
let server_pid = sysinfo::get_current_pid().unwrap();
|
||||
|
||||
|
@ -67,13 +67,7 @@ impl Data {
|
|||
|
||||
let http_payload_size_limit = opt.http_payload_size_limit;
|
||||
|
||||
let db = match Database::open_or_create(opt.db_path, db_opt) {
|
||||
Ok(db) => Arc::new(db),
|
||||
Err(e) => {
|
||||
error!("{}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
let db = Arc::new(Database::open_or_create(opt.db_path, db_opt)?);
|
||||
|
||||
let mut api_keys = ApiKeys {
|
||||
master: opt.master_key,
|
||||
|
@ -100,6 +94,6 @@ impl Data {
|
|||
index_update_callback(&index_uid, &callback_context, status);
|
||||
}));
|
||||
|
||||
data
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ async fn main() -> Result<(), MainError> {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let data = Data::new(opt.clone());
|
||||
let data = Data::new(opt.clone())?;
|
||||
|
||||
if !opt.no_analytics {
|
||||
let analytics_data = data.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue