Load environment from file
This commit is contained in:
parent
f7b0150688
commit
5fc7584100
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2091,6 +2091,7 @@ name = "soundfx-rs"
|
||||
version = "1.5.7"
|
||||
dependencies = [
|
||||
"dashmap",
|
||||
"dotenv",
|
||||
"env_logger",
|
||||
"lazy_static",
|
||||
"log",
|
||||
|
@ -19,6 +19,7 @@ log = "0.4"
|
||||
serde_json = "1.0"
|
||||
dashmap = "5.3"
|
||||
serde = "1.0"
|
||||
dotenv = "0.15.0"
|
||||
|
||||
[patch."https://github.com/serenity-rs/serenity"]
|
||||
serenity = { version = "0.11.5" }
|
||||
@ -29,7 +30,7 @@ suggests = "mysql-server-8.0"
|
||||
maintainer-scripts = "debian"
|
||||
assets = [
|
||||
["target/release/soundfx-rs", "usr/bin/soundfx-rs", "755"],
|
||||
["conf/default", "etc/soundfx-rs/default", "600"]
|
||||
["conf/default.env", "etc/soundfx-rs/default.env", "600"]
|
||||
]
|
||||
|
||||
[package.metadata.deb.systemd-units]
|
||||
|
7
conf/default.env
Normal file
7
conf/default.env
Normal file
@ -0,0 +1,7 @@
|
||||
DISCORD_TOKEN=
|
||||
DATABASE_URL=mysql://localhost/soundfx
|
||||
UPLOAD_MAX_SIZE=2097152
|
||||
MAX_SOUNDS=8
|
||||
CACHING_LOCATION=/tmp
|
||||
PATREON_GUILD=
|
||||
PATREON_ROLE=
|
@ -8,7 +8,7 @@ mod event_handlers;
|
||||
mod models;
|
||||
mod utils;
|
||||
|
||||
use std::{env, sync::Arc};
|
||||
use std::{env, path::Path, sync::Arc};
|
||||
|
||||
use dashmap::DashMap;
|
||||
use poise::serenity_prelude::{
|
||||
@ -68,6 +68,10 @@ pub async fn register_application_commands(
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
if Path::new("/etc/soundfx-rs/default.env").exists() {
|
||||
dotenv::from_path("/etc/soundfx-rs/default.env").unwrap();
|
||||
}
|
||||
|
||||
env_logger::init();
|
||||
|
||||
let discord_token = env::var("DISCORD_TOKEN").expect("Missing DISCORD_TOKEN from environment");
|
||||
|
Loading…
Reference in New Issue
Block a user