Commit 7fbb0887 authored by Aljaž Srebrnič's avatar Aljaž Srebrnič

Allow passing redis connection string as env var

parent 805c1e0b
......@@ -6,6 +6,8 @@ use spaceapi_server::SpaceapiServerBuilder;
use spaceapi_server::api;
use spaceapi_server::modifiers::StatusModifier;
use std::env::var;
use r2d2;
use r2d2_redis::RedisConnectionManager;
use redis;
......@@ -65,7 +67,11 @@ fn main() {
.build()
.expect("Creating status failed");
let manager = RedisConnectionManager::new("redis://localhost").unwrap();
let redis_connstring = match var("REDIS_CONNSTRING") {
Ok(s) => s,
Err(_) => String::from("http://localhost")
};
let manager = RedisConnectionManager::new(&*redis_connstring).unwrap();
let pool = RedisPool::builder()
.build(manager)
.unwrap();
......@@ -73,7 +79,7 @@ fn main() {
// Set up server
let server = SpaceapiServerBuilder::new(status)
// .add_redis_pool(pool) waiting for
.redis_connection_info("redis://localhost")
.redis_connection_info(&*redis_connstring)
.add_status_modifier(OpenStatusFromRedisModifier::new(pool))
.build()
.expect("Could not initialize server");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment