move env file to etc folder
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use diesel::pg::PgConnection;
|
use diesel::pg::PgConnection;
|
||||||
use diesel::result::Error;
|
use diesel::result::Error;
|
||||||
use dotenvy::dotenv;
|
use dotenvy::{from_path};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::path::Path;
|
||||||
use serde::{Serialize};
|
use serde::{Serialize};
|
||||||
use diesel_derive_enum::DbEnum;
|
use diesel_derive_enum::DbEnum;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@@ -49,7 +50,8 @@ pub struct NewDid<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn connect() -> PgConnection {
|
pub fn connect() -> PgConnection {
|
||||||
dotenv().ok();
|
let env_path = Path::new("/etc/did_router.conf");
|
||||||
|
from_path(env_path).expect("env file missed");
|
||||||
|
|
||||||
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||||
PgConnection::establish(&database_url)
|
PgConnection::establish(&database_url)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use dotenvy::dotenv;
|
use dotenvy::{from_path};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::path::Path;
|
||||||
use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
|
use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
|
||||||
use super::database as db;
|
use super::database as db;
|
||||||
use super::database::{DidTargetType, Did};
|
use super::database::{DidTargetType, Did};
|
||||||
@@ -42,7 +43,9 @@ pub fn external_number(did: Did) -> XMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn no_service(_did: Did) -> XMLElement {
|
pub fn no_service(_did: Did) -> XMLElement {
|
||||||
dotenv().ok();
|
let env_path = Path::new("/etc/did_router.conf");
|
||||||
|
from_path(env_path).expect("env file missed");
|
||||||
|
|
||||||
let sound_path = env::var("SOUND_PATH").expect("SOUND_PATH must be set");
|
let sound_path = env::var("SOUND_PATH").expect("SOUND_PATH must be set");
|
||||||
let no_service_path = format!("{}/no_service.wav", sound_path);
|
let no_service_path = format!("{}/no_service.wav", sound_path);
|
||||||
let mut work = XMLElement::new("work");
|
let mut work = XMLElement::new("work");
|
||||||
@@ -53,7 +56,9 @@ pub fn no_service(_did: Did) -> XMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn night_mode(_did: Did) -> XMLElement {
|
pub fn night_mode(_did: Did) -> XMLElement {
|
||||||
dotenv().ok();
|
let env_path = Path::new("/etc/did_router.conf");
|
||||||
|
from_path(env_path).expect("env file missed");
|
||||||
|
|
||||||
let sound_path = env::var("SOUND_PATH").expect("SOUND_PATH must be set");
|
let sound_path = env::var("SOUND_PATH").expect("SOUND_PATH must be set");
|
||||||
let night_mode_path = format!("{}/night_mode.wav", sound_path);
|
let night_mode_path = format!("{}/night_mode.wav", sound_path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user