Skip to content

Commit

Permalink
cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
ParzivalEugene committed May 6, 2024
1 parent fd3fa8d commit 61783f5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
18 changes: 16 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
LOGGER_PORT=3000
MONGO_URL=mongo_url
# Logger Configuration
LOGGER_HOST=0.0.0.0
LOGGER_PORT=560
LOGGER_URI=${LOGGER_HOST}:${LOGGER_PORT}

# MongoDB Configuration
MONGO_URL=mongodb://helios:pass@logs:1111
LOGS_DATABASE_USER=helios
LOGS_DATABASE_PASSWORD=pass
LOGS_DATABASE_HOST=logs
LOGS_DATABASE_PORT=1111

# Logs Viewer Configuration
LOGS_VIEWER_USER=helios
LOGS_VIEWER_PASSWORD=pass
LOGS_VIEWER_PORT=1212
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
.env
.env
.env.production
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Helios | Logger

[![AGPL-3.0 License](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://choosealicense.com/licenses/agpl-3.0/)

The Logger is a simple HTTP server that accepts log entries and stores them in a MongoDB database.

## Features
Expand Down Expand Up @@ -60,3 +62,4 @@ To send a log entry to the service, you can use tools like cURL or Postman. Here
```bash
curl -X POST -H "Content-Type: application/json" -d '{"message": "This is a log message"}' http://localhost:<LOGGER_PORT>/log
```
7 changes: 2 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ use std::env;

#[derive(Debug, Clone)]
pub struct Config {
pub logger_port: u16,
pub logger_uri: String,
pub mongo_url: String,
}

pub static ENV: Lazy<Config> = Lazy::new(|| {
dotenv().ok();
Config {
logger_port: env::var("LOGGER_PORT")
.expect("LOGGER_PORT must be set")
.parse()
.expect("LOGGER_PORT must be a number"),
logger_uri: env::var("LOGGER_URI").expect("LOGGER_URI must be set"),
mongo_url: env::var("MONGO_URL").expect("MONGO_URL must be set"),
}
});
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ async fn main() {
let app = Router::new()
.route("/log", post(log))
.with_state(AppState { client });
let listener = TcpListener::bind(format!("localhost:{}", ENV.logger_port))
let listener = TcpListener::bind(&ENV.logger_uri)
.await
.unwrap();

println!("Listening on http://localhost:{}", ENV.logger_port);
println!("Listening on http://{}", ENV.logger_uri);
axum::serve(listener, app).await.unwrap()
}

Expand Down

0 comments on commit 61783f5

Please sign in to comment.