-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa7b7b5
commit bfed6a4
Showing
8 changed files
with
722 additions
and
492 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
FROM rust:1.80 as builder | ||
FROM rust:1.82 as builder | ||
WORKDIR /usr/src/myapp | ||
COPY . . | ||
ARG github_token | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
use std::env; | ||
|
||
use crate::structs::old_games; | ||
use bf_sparta::cookie::Cookie; | ||
use bson::Document; | ||
|
@@ -57,10 +59,11 @@ pub struct ManagerInfo { | |
|
||
impl MongoClient { | ||
pub async fn connect() -> Result<Self> { | ||
// Possible env | ||
const MONGO_URL: &str = "mongodb://zjobse:[email protected]:27017"; | ||
// Try connect to mongo client | ||
let client = Client::with_uri_str(MONGO_URL).await?; | ||
let client = Client::with_uri_str( | ||
env::var("MONGO_DETAILS_STRING").expect("MONGO_DETAILS_STRING wasn't set"), | ||
) | ||
.await?; | ||
|
||
// Server manager DB | ||
let db = client.database("serverManager"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ use influxdb2::Client; | |
use sqlx::postgres::PgPool; | ||
use std::{ | ||
collections::HashMap, | ||
env, | ||
ops::Add, | ||
sync::{atomic, Arc}, | ||
time::Duration, | ||
|
@@ -20,6 +21,11 @@ use warp::Filter; | |
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
match dotenvy::dotenv() { | ||
Ok(_) => {} | ||
Err(_) => log::info!(".env not found, using env variables..."), | ||
}; | ||
|
||
let mins_between_runs = 5; | ||
let hours_between_detailed_runs = 12; | ||
let last_update = Arc::new(atomic::AtomicI64::new(chrono::Utc::now().timestamp() / 60)); | ||
|
@@ -50,17 +56,17 @@ async fn main() -> anyhow::Result<()> { | |
}); | ||
|
||
let influx_client = Client::new( | ||
"http://167.235.137.239:8086/", | ||
"Gametools", | ||
"B_wltARyGe85ohqEYFH0xX9lTQAtw4DdQf0tcee8IcptUInOpZx3oVmnjBSRSDHKV1nEl63xQS8sqCQO7xbETg==", | ||
env::var("INFLUX_URL").expect("INFLUX_URL wasn't set"), | ||
env::var("INFLUX_USER").expect("INFLUX_USER wasn't set"), | ||
env::var("INFLUX_PASS").expect("INFLUX_PASS wasn't set"), | ||
); | ||
let mut mongo_client = MongoClient::connect().await?; | ||
|
||
let pool = | ||
PgPool::connect("postgres://gametools:[email protected]:5432/tsdb") | ||
.await?; | ||
let pool = PgPool::connect(&env::var("DATABASE_URL").expect("DATABASE_URL wasn't set")).await?; | ||
|
||
let api_main_account = env::var("API_MAIN_ACCOUNT").expect("API_MAIN_ACCOUNT wasn't set"); | ||
|
||
let mut cookie = match mongo_client.get_cookies("[email protected]").await { | ||
let mut cookie = match mongo_client.get_cookies(&api_main_account).await { | ||
Ok(result) => result, | ||
Err(_) => bf_sparta::cookie::Cookie { | ||
sid: "".to_string(), | ||
|
@@ -73,16 +79,17 @@ async fn main() -> anyhow::Result<()> { | |
Err(e) => { | ||
log::warn!("Cookie failed, {} - requesting new cookie", e); | ||
let cookie_auth = cookie_request::request_cookie(cookie_request::Login { | ||
email: "[email protected]".to_string(), | ||
pass: "bqgPAHJDphaTpPcbRk8jfHhbCecnTnRN".to_string(), | ||
email: api_main_account.clone(), | ||
pass: env::var("API_MAIN_ACCOUNT_PASSWORD") | ||
.expect("API_MAIN_ACCOUNT_PASSWORD wasn't set"), | ||
}) | ||
.await?; | ||
let cookie = bf_sparta::cookie::Cookie { | ||
sid: cookie_auth.sid, | ||
remid: cookie_auth.remid, | ||
}; | ||
mongo_client | ||
.push_new_cookies("[email protected]", &cookie) | ||
.push_new_cookies(&api_main_account, &cookie) | ||
.await?; | ||
cookie | ||
} | ||
|