mirror of
https://github.com/freedit-org/freedit.git
synced 2026-01-08 20:18:07 -05:00
use debug_assertions instead of build.rs
This commit is contained in:
5
build.rs
5
build.rs
@@ -1,11 +1,6 @@
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match std::env::var("PROFILE") {
|
|
||||||
Ok(key) if key.as_str() == "debug" => println!("cargo:rustc-env=PROFILE=debug"),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut git_commit = match Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
let mut git_commit = match Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
||||||
Ok(output) if !output.stdout.is_empty() => {
|
Ok(output) if !output.stdout.is_empty() => {
|
||||||
String::from_utf8_lossy(&output.stdout).to_string()
|
String::from_utf8_lossy(&output.stdout).to_string()
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@@ -12,7 +12,6 @@ use freedit::{
|
|||||||
error::AppError,
|
error::AppError,
|
||||||
DB, VERSION,
|
DB, VERSION,
|
||||||
};
|
};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use std::{fs, path::PathBuf};
|
use std::{fs, path::PathBuf};
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
@@ -24,9 +23,6 @@ use tikv_jemallocator::Jemalloc;
|
|||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: Jemalloc = Jemalloc;
|
static GLOBAL: Jemalloc = Jemalloc;
|
||||||
|
|
||||||
static IS_DEBUG: Lazy<bool> =
|
|
||||||
Lazy::new(|| matches!(std::env::var("PROFILE"), Ok(key) if key.as_str() == "debug"));
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), AppError> {
|
async fn main() -> Result<(), AppError> {
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
@@ -34,9 +30,9 @@ async fn main() -> Result<(), AppError> {
|
|||||||
.with(tracing_subscriber::fmt::layer())
|
.with(tracing_subscriber::fmt::layer())
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
if !*IS_DEBUG {
|
// only create snapshot in release mode
|
||||||
create_snapshot(&DB);
|
#[cfg(not(debug_assertions))]
|
||||||
}
|
create_snapshot(&DB);
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
loop {
|
loop {
|
||||||
@@ -116,7 +112,7 @@ async fn main() -> Result<(), AppError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: TEST with https://github.com/hatoo/oha
|
// TODO: TEST with https://github.com/hatoo/oha
|
||||||
|
#[allow(dead_code)]
|
||||||
fn create_snapshot(db: &sled::Db) {
|
fn create_snapshot(db: &sled::Db) {
|
||||||
let checksum = db.checksum().unwrap();
|
let checksum = db.checksum().unwrap();
|
||||||
info!(%checksum);
|
info!(%checksum);
|
||||||
|
|||||||
Reference in New Issue
Block a user