MCPcopy Create free account
hub / github.com/3eif/gitmotion / main

Function main

api/src/main.rs:788–870  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

786
787#[actix_web::main]
788async fn main() -> std::io::Result<()> {
789 dotenv().ok();
790
791 // Custom logger configuration
792 Builder::new()
793 .format(|buf, record| {
794 writeln!(
795 buf,
796 "{} {} [{}] {}",
797 buf.timestamp(),
798 record.level(),
799 record.target(),
800 record.args()
801 )
802 })
803 .filter(None, LevelFilter::Info)
804 .init();
805
806 let output_dir = Path::new("/gource_videos");
807 if !output_dir.exists() {
808 fs::create_dir_all(output_dir)?;
809 }
810
811 if let Err(e) = check_dependencies() {
812 log_message(
813 log::Level::Error,
814 &format!("Dependency check failed: {}", e),
815 None,
816 );
817 return Err(std::io::Error::new(std::io::ErrorKind::Other, e));
818 }
819
820 let job_store = web::Data::new(JobStore::default());
821
822 // Set up periodic task to clear gource_videos
823 let job_store_clone = job_store.clone();
824 tokio::spawn(async move {
825 let mut interval = interval(Duration::from_secs(3600)); // 1 hour
826 loop {
827 interval.tick().await;
828 clear_gource_videos(job_store_clone.clone()).await;
829 }
830 });
831
832 let api_port = env::var("API_PORT").unwrap_or_else(|_| {
833 log_message(
834 log::Level::Info,
835 "API_PORT not set, using default port 8081",
836 None,
837 );
838 "8081".to_string()
839 });
840 log_message(
841 log::Level::Info,
842 &format!("API port set to: {}", api_port),
843 None,
844 );
845

Callers

nothing calls this directly

Calls 3

check_dependenciesFunction · 0.85
log_messageFunction · 0.85
clear_gource_videosFunction · 0.85

Tested by

no test coverage detected