From 6aa6c70af607ede55f9dafef7278b192a2a6b9d0 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 9 Nov 2018 19:47:46 +0100 Subject: Set up a file logger Get a file path from the `LOG_FILE` environment variable and use it for log output. Call `database::get_database_connection()` and log the error if it fails. Worried about exiting early from the FastCGI program, as DreamHost says this causes problems (https://help.dreamhost.com/hc/en-us/articles/217298967). But I don't see how the program can continue without a database connection. Return a `Result` from `main()` because it's easier to use the `?` operator for errors that happen before logging is initialised. --- license-generator/src/database.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'license-generator/src/database.rs') diff --git a/license-generator/src/database.rs b/license-generator/src/database.rs index 28673c4..94e925f 100644 --- a/license-generator/src/database.rs +++ b/license-generator/src/database.rs @@ -4,7 +4,7 @@ use mysql; use errors::*; -fn get_database_connection() -> Result { +pub fn get_database_connection() -> Result { let connection_url = env::var("DATABASE_URL")?; let pool = mysql::Pool::new_manual(10, 50, connection_url)?; let cx = pool.get_conn()?; -- cgit v1.2.3