1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 15:29:21 +00:00
comunicapiv3/src/main.rs

29 lines
1000 B
Rust
Raw Normal View History

2021-02-13 15:36:39 +00:00
use comunic_server::{cleanup_thread, server};
2021-03-02 17:57:34 +00:00
use comunic_server::api_data::conversation_message_api::ConversationMessageAPI;
2020-05-20 17:05:59 +00:00
use comunic_server::data::config::{conf, Config};
2021-03-02 17:57:34 +00:00
use comunic_server::helpers::{conversations_helper, database};
2020-05-22 06:51:15 +00:00
2020-05-21 13:28:07 +00:00
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
2021-02-12 16:35:26 +00:00
let conf_file = match std::env::args().skip(1).next() {
Some(el) => el,
None => "config.yaml".to_string(),
};
2020-05-20 17:05:59 +00:00
// Load configuration
2021-02-12 16:35:26 +00:00
Config::load(&conf_file).expect("Could not load configuration!");
2020-05-20 17:05:59 +00:00
2020-05-21 07:21:58 +00:00
// Connect to the database
database::connect(&conf().database).expect("Could not connect to database!");
2020-05-20 17:05:59 +00:00
2021-02-13 15:36:39 +00:00
// Start cleanup thread
cleanup_thread::start().expect("Failed to start cleanup thread!");
2021-03-02 17:57:34 +00:00
let msg = conversations_helper::get_last_messages(120, 100).unwrap();
println!("{:#?}", msg);
println!("{:#?}", serde_json::to_string(&ConversationMessageAPI::for_list(&msg)));
2020-05-21 13:28:07 +00:00
// Start the server
server::start_server(conf()).await
2020-05-20 15:46:05 +00:00
}