Using .env config
This commit is contained in:
@@ -25,6 +25,7 @@ target
|
|||||||
|
|
||||||
/target
|
/target
|
||||||
|
|
||||||
|
.env
|
||||||
|
|
||||||
*.db
|
*.db
|
||||||
config.json
|
config.json
|
||||||
@@ -2,6 +2,32 @@
|
|||||||
|
|
||||||
The server for the DM and notification system of Voxa
|
The server for the DM and notification system of Voxa
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
### Using `config.json` (Usually when you self host)
|
||||||
|
|
||||||
|
`cargo run`
|
||||||
|
|
||||||
|
### Using `.env`
|
||||||
|
|
||||||
|
```python
|
||||||
|
#.env
|
||||||
|
VX_CONFIG='{"server_name":"Server Name","server_id":"<required>","server_key":"<required>","port":7090,"channels":[]}'
|
||||||
|
```
|
||||||
|
|
||||||
|
If your env is automatically loaded
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
Run this if you are running on self host or when the .env isn't automatically loaded
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -a; source .env; set +a
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
### What is a Voxa Node?
|
### What is a Voxa Node?
|
||||||
|
|
||||||
A voxa node is a server that handles DMs sent to you and push message notifications, a client will keep a constant connection with their chosen node and when a sender wants to send a DM or a message notification they can make a HTTP request to the same port, it's important to note that a node server only handles the receiving side, unless both parties are in the same node.
|
A voxa node is a server that handles DMs sent to you and push message notifications, a client will keep a constant connection with their chosen node and when a sender wants to send a DM or a message notification they can make a HTTP request to the same port, it's important to note that a node server only handles the receiving side, unless both parties are in the same node.
|
||||||
|
|||||||
+9
-1
@@ -5,6 +5,7 @@ mod server;
|
|||||||
mod types;
|
mod types;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub use anyhow::Context as ErrorContext;
|
pub use anyhow::Context as ErrorContext;
|
||||||
@@ -16,7 +17,14 @@ use crate::utils::vfs;
|
|||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let root = PathBuf::from("");
|
let root = PathBuf::from("");
|
||||||
let config: ServerConfig = vfs::read_config(&root.join("config.json"))?;
|
|
||||||
|
let config: ServerConfig = if let Ok(env_config) = env::var("VX_CONFIG") {
|
||||||
|
serde_json::from_str(&env_config)?
|
||||||
|
} else {
|
||||||
|
vfs::read_config(&root.join("config.json"))?
|
||||||
|
};
|
||||||
|
|
||||||
config.build(&root).run()?;
|
config.build(&root).run()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user