|
| 1 | +use std::env; |
1 | 2 | use std::error::Error;
|
2 | 3 | use std::path::PathBuf;
|
3 | 4 | use std::sync::{Arc, Mutex};
|
@@ -47,15 +48,33 @@ impl App {
|
47 | 48 |
|
48 | 49 | github.scopes.push(String::from("read:org"));
|
49 | 50 |
|
| 51 | + let db_pool_size = match (env::var("DB_POOL_SIZE"), config.env) { |
| 52 | + (Ok(num), _) => num.parse().expect("couldn't parse DB_POOL_SIZE"), |
| 53 | + (_, ::Env::Production) => 10, |
| 54 | + _ => 1, |
| 55 | + }; |
| 56 | + |
| 57 | + let db_min_idle = match (env::var("DB_MIN_IDLE"), config.env) { |
| 58 | + (Ok(num), _) => Some(num.parse().expect("couldn't parse DB_MIN_IDLE")), |
| 59 | + (_, ::Env::Production) => Some(5), |
| 60 | + _ => None, |
| 61 | + }; |
| 62 | + |
| 63 | + let db_helper_threads = match (env::var("DB_HELPER_THREADS"), config.env) { |
| 64 | + (Ok(num), _) => num.parse().expect("couldn't parse DB_HELPER_THREADS"), |
| 65 | + (_, ::Env::Production) => 3, |
| 66 | + _ => 1, |
| 67 | + }; |
| 68 | + |
50 | 69 | let db_config = r2d2::Config::builder()
|
51 |
| - .pool_size(if config.env == ::Env::Production {10} else {1}) |
52 |
| - .min_idle(if config.env == ::Env::Production {Some(5)} else {None}) |
53 |
| - .helper_threads(if config.env == ::Env::Production {3} else {1}) |
| 70 | + .pool_size(db_pool_size) |
| 71 | + .min_idle(db_min_idle) |
| 72 | + .helper_threads(db_helper_threads) |
54 | 73 | .build();
|
55 | 74 | let diesel_db_config = r2d2::Config::builder()
|
56 |
| - .pool_size(if config.env == ::Env::Production {30} else {1}) |
57 |
| - .min_idle(if config.env == ::Env::Production {Some(5)} else {None}) |
58 |
| - .helper_threads(if config.env == ::Env::Production {3} else {1}) |
| 75 | + .pool_size(db_pool_size) |
| 76 | + .min_idle(db_min_idle) |
| 77 | + .helper_threads(db_helper_threads) |
59 | 78 | .build();
|
60 | 79 |
|
61 | 80 | let repo = git2::Repository::open(&config.git_repo_checkout).unwrap();
|
|
0 commit comments