feat(cron::update) auto update git repo and update db index

This commit is contained in:
lumither committed 2024-11-27 00:18:08 -08:00
1 parent 99a19d8d9e
commit bacaea80a3
18 files changed
+882 -39

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
use git2::opts::{set_server_connect_timeout_in_milliseconds, set_server_timeout_in_milliseconds};
use tracing::warn;
pub fn init() {
// git2 option
unsafe {
if let Err(e) = set_server_connect_timeout_in_milliseconds(10_000) {
warn!("failed to set git2 server connect timeout: {}", e);
}
if let Err(e) = set_server_timeout_in_milliseconds(60_000) {
warn!("failed to set git2 server timeout: {}", e);
}
}
}
+3
View File
@@ -1,6 +1,7 @@
mod cron;
mod database;
pub mod logger;
mod misc;
mod schema;
pub mod server;
@@ -24,6 +25,8 @@ pub fn load_env() {
}
pub async fn start() {
misc::init();
// connect database
let db_pool = match database::init().await {
Ok(pool) => {
+2 -2
View File
@@ -7,11 +7,11 @@ CREATE TABLE IF NOT EXISTS Post
post_id UUID PRIMARY KEY,
title VARCHAR(255) NOT NULL,
category VARCHAR(255) NOT NULL,
header_img TEXT,
filename TEXT UNIQUE NOT NULL,
summary TEXT,
sub_title TEXT,
content TEXT NOT NULL,
last_update TIMESTAMPTZ NOT NULL,
last_update TIMESTAMPTZ,
first_update TIMESTAMPTZ NOT NULL
);
"##;