merge w/ gtfs
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled

This commit is contained in:
Nicholas Orlowsky 2025-11-08 13:14:36 -05:00
commit 786f32e7e3
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
39 changed files with 1220 additions and 1515 deletions

View file

@ -3,18 +3,17 @@ use env_logger::Env;
use log::*;
use dotenv::dotenv;
use serde::Deserialize;
use services::trip_tracking::{self};
use services::{gtfs_pull, trip_tracking::{self}};
use templates::ContentTemplate;
use std::{sync::Arc, time::Instant};
use std::{fs::File, io::Read, sync::Arc, time::Instant};
use askama::Template;
mod database;
mod services;
mod controllers;
mod templates;
pub struct AppState {
database: ::sqlx::postgres::PgPool,
gtfs_service: services::gtfs_pull::GtfsPullService,
trip_tracking_service: services::trip_tracking::TripTrackingService
}
@ -79,19 +78,22 @@ async fn main() -> ::anyhow::Result<()> {
let version: &str = option_env!("CARGO_PKG_VERSION").expect("Expected package version");
info!("Starting the SEPTASTIC Server v{} (commit: {})", version, "NONE");
let connection_string =
std::env::var("DB_CONNSTR").expect("Expected database connection string");
let mut file = File::open("./config.yaml")?;
let mut file_contents = String::new();
file.read_to_string(&mut file_contents);
let pool = ::sqlx::postgres::PgPoolOptions::new()
.max_connections(5)
.connect(&connection_string)
.await?;
let config_file = serde_yaml::from_str::<gtfs_pull::Config>(file_contents.as_str())?;
let tt_service = trip_tracking::TripTrackingService::new();
let tt_service = services::trip_tracking::TripTrackingService::new();
tt_service.start();
let svc = gtfs_pull::GtfsPullService::new(config_file);
svc.start();
svc.wait_for_ready();
let state = Arc::new(AppState {
database: pool,
gtfs_service: svc,
trip_tracking_service: tt_service
});