Merge pull request #12 from mozilla/3-dockerflow-env

Read GEOIP_DB_PATH from env (ref #4)
This commit is contained in:
Mike Cooper 2018-12-13 10:57:02 -08:00 коммит произвёл GitHub
Родитель 81b7d10958 9e47898a3c
Коммит 733f5b1c42
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -17,6 +17,14 @@ This project should run on the latest stable version of Rust. Unstable features
A GeoIP database is required. For development purposes, one can be obtained from [the Maxmind website](https://dev.maxmind.com/geoip/geoip2/geolite2/). The GeoLite2 Country database is recommended. It should be placed at the root of the repository.
## Configuration
Via environment variables:
- `HOST`: host (default: `localhost`)
- `PORT`: port number (default: `8080`)
- `GEOIP_DB_PATH`: path to GeoIP database (default: `./GeoLite2-Country.mmdb`)
## Tests
Tests can be run with Cargo as well

Просмотреть файл

@ -31,7 +31,8 @@ fn main() {
let sys = actix::System::new("classify-client");
let geoip = actix::SyncArbiter::start(1, || {
let geoip_path = "./GeoLite2-Country.mmdb";
let geoip_path =
env::var("GEOIP_DB_PATH").unwrap_or_else(|_| "./GeoLite2-Country.mmdb".to_string());
GeoIpActor::from_path(&geoip_path).unwrap_or_else(|err| {
panic!(format!(
"Could not open geoip database at {:?}: {}",