mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-02 16:38:14 +00:00
configure redis with env var
This commit is contained in:
1 parent
c416069f69
commit
30dfe649ae
6 files changed
+24
-13
No files matched your search
+10
-3
@@ -78,7 +78,9 @@ use crate::http_server::endpoints::w2l::set_w2l_template_mod_approval::set_w2l_t
|
||||
use crate::http_server::web_utils::cookie_manager::CookieManager;
|
||||
use crate::http_server::web_utils::session_checker::SessionChecker;
|
||||
use crate::server_state::{ServerState, EnvConfig};
|
||||
use crate::shared_constants::{DEFAULT_RUST_LOG, DEFAULT_MYSQL_PASSWORD};
|
||||
use crate::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING;
|
||||
use crate::shared_constants::DEFAULT_REDIS_CONNECTION_STRING;
|
||||
use crate::shared_constants::DEFAULT_RUST_LOG;
|
||||
use crate::util::encrypted_sort_id::SortKeyCrypto;
|
||||
use log::{info};
|
||||
use r2d2_redis::RedisConnectionManager;
|
||||
@@ -141,7 +143,12 @@ async fn main() -> AnyhowResult<()> {
|
||||
let db_connection_string =
|
||||
easyenv::get_env_string_or_default(
|
||||
"MYSQL_URL",
|
||||
DEFAULT_MYSQL_PASSWORD);
|
||||
DEFAULT_MYSQL_CONNECTION_STRING);
|
||||
|
||||
let redis_connection_string =
|
||||
easyenv::get_env_string_or_default(
|
||||
"REDIS_URL",
|
||||
DEFAULT_REDIS_CONNECTION_STRING);
|
||||
|
||||
let pool = MySqlPoolOptions::new()
|
||||
.max_connections(5)
|
||||
@@ -152,7 +159,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
mysql_pool: pool.clone(), // NB: Pool is clone/sync/send-safe
|
||||
};
|
||||
|
||||
let redis_manager = RedisConnectionManager::new("redis://localhost")?;
|
||||
let redis_manager = RedisConnectionManager::new(redis_connection_string)?;
|
||||
|
||||
let redis_pool = r2d2::Pool::builder()
|
||||
.build(redis_manager)?;
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
//! Shared constants that all binaries use.
|
||||
//! Or at least that deserve extremely high visibility.
|
||||
|
||||
/// NB: `sqlx::query` is spammy and dumps all queries as "info"-level log lines.
|
||||
/// NB: `hyper::proto::h1::io` is incredibly spammy and logs every chunk of bytes in very large files being downloaded.
|
||||
pub const DEFAULT_RUST_LOG: &'static str = "debug,actix_web=info,sqlx::query=warn,hyper::proto::h1::io=warn";
|
||||
//const DEFAULT_RUST_LOG: &'static str = "debug,actix_web=info"; // but sometimes we want to debug
|
||||
|
||||
/// The default MySql password for use in development
|
||||
pub const DEFAULT_MYSQL_PASSWORD: &'static str = "mysql://storyteller:password@localhost/storyteller";
|
||||
/// The default Redis connection string for use in development
|
||||
pub const DEFAULT_REDIS_CONNECTION_STRING: &'static str = "redis://localhost";
|
||||
|
||||
/// The default MySql connection string for use in development
|
||||
pub const DEFAULT_MYSQL_CONNECTION_STRING: &'static str = "mysql://storyteller:password@localhost/storyteller";
|
||||
|
||||
/// The number of results we return by default for paginated queries.
|
||||
pub const DEFAULT_MYSQL_QUERY_RESULT_PAGE_SIZE: u16 = 25;
|
||||
@@ -41,7 +41,7 @@ use crate::util::random_crockford_token::random_crockford_token;
|
||||
use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE};
|
||||
use log::{warn, info};
|
||||
use ring::digest::{Context, Digest, SHA256};
|
||||
use shared_constants::DEFAULT_MYSQL_PASSWORD;
|
||||
use shared_constants::DEFAULT_MYSQL_CONNECTION_STRING;
|
||||
use shared_constants::DEFAULT_RUST_LOG;
|
||||
use sqlx::MySqlPool;
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
@@ -136,7 +136,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
let db_connection_string =
|
||||
easyenv::get_env_string_or_default(
|
||||
"MYSQL_URL",
|
||||
DEFAULT_MYSQL_PASSWORD);
|
||||
DEFAULT_MYSQL_CONNECTION_STRING);
|
||||
|
||||
info!("Connecting to database...");
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ use crate::util::semi_persistent_cache_dir::SemiPersistentCacheDir;
|
||||
use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE};
|
||||
use log::{warn, info};
|
||||
use ring::digest::{Context, Digest, SHA256};
|
||||
use shared_constants::DEFAULT_MYSQL_PASSWORD;
|
||||
use shared_constants::DEFAULT_MYSQL_CONNECTION_STRING;
|
||||
use shared_constants::DEFAULT_RUST_LOG;
|
||||
use sqlx::MySqlPool;
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
@@ -160,7 +160,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
let db_connection_string =
|
||||
easyenv::get_env_string_or_default(
|
||||
"MYSQL_URL",
|
||||
DEFAULT_MYSQL_PASSWORD);
|
||||
DEFAULT_MYSQL_CONNECTION_STRING);
|
||||
|
||||
info!("Connecting to database...");
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ use crate::util::random_crockford_token::random_crockford_token;
|
||||
use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE};
|
||||
use log::{warn, info};
|
||||
use ring::digest::{Context, Digest, SHA256};
|
||||
use shared_constants::DEFAULT_MYSQL_PASSWORD;
|
||||
use shared_constants::DEFAULT_MYSQL_CONNECTION_STRING;
|
||||
use shared_constants::DEFAULT_RUST_LOG;
|
||||
use sqlx::MySqlPool;
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
@@ -183,7 +183,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
let db_connection_string =
|
||||
easyenv::get_env_string_or_default(
|
||||
"MYSQL_URL",
|
||||
DEFAULT_MYSQL_PASSWORD);
|
||||
DEFAULT_MYSQL_CONNECTION_STRING);
|
||||
|
||||
info!("Connecting to database...");
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ use crate::util::semi_persistent_cache_dir::SemiPersistentCacheDir;
|
||||
use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE};
|
||||
use log::{warn, info};
|
||||
use ring::digest::{Context, Digest, SHA256};
|
||||
use shared_constants::DEFAULT_MYSQL_PASSWORD;
|
||||
use shared_constants::DEFAULT_MYSQL_CONNECTION_STRING;
|
||||
use shared_constants::DEFAULT_RUST_LOG;
|
||||
use sqlx::MySqlPool;
|
||||
use sqlx::mysql::MySqlPoolOptions;
|
||||
@@ -179,7 +179,7 @@ async fn main() -> AnyhowResult<()> {
|
||||
let db_connection_string =
|
||||
easyenv::get_env_string_or_default(
|
||||
"MYSQL_URL",
|
||||
DEFAULT_MYSQL_PASSWORD);
|
||||
DEFAULT_MYSQL_CONNECTION_STRING);
|
||||
|
||||
info!("Connecting to database...");
|
||||
|
||||
|
||||
Reference in new issue
Block a user