Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docker UX #367

Merged
merged 5 commits into from
Aug 9, 2023

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Aug 8, 2023

Some minor improvements to make using docker and the app configuration a smoother experience.

@josecelano josecelano linked an issue Aug 8, 2023 that may be closed by this pull request
4 tasks
@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Merging #367 (ec7bd7d) into develop (b09e95a) will decrease coverage by 0.06%.
Report is 1 commits behind head on develop.
The diff coverage is 4.16%.

@@             Coverage Diff             @@
##           develop     #367      +/-   ##
===========================================
- Coverage    85.07%   85.01%   -0.06%     
===========================================
  Files           88       89       +1     
  Lines         6564     6567       +3     
===========================================
- Hits          5584     5583       -1     
- Misses         980      984       +4     
Files Changed Coverage Δ
src/bootstrap/app.rs 75.00% <ø> (+19.44%) ⬆️
src/bootstrap/config.rs 0.00% <0.00%> (ø)
packages/configuration/src/lib.rs 81.98% <16.66%> (+3.28%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

All of then have the ENV_VAR prefix now. Like in the Index Backend.
So we can identify constants that are related to env vars.
Now you can change the deafult location for the config file with an env
var:

```
TORRUST_IDX_BACK_CONFIG_PATH="./storage/config.toml" cargo run
```

The default location is still `./config.toml`
Instead of halting the program, not the tracker continues the execution
when no config.toml file is provided and the default one is created.

It shows some messages:

```
Loading configuration from configuration file: `./config.toml` ...
Missing configuration file.
Creating a default configuration file: `./config.toml` ...
Please review the config file: `./config.toml` and restart the tracker if needed.
2023-08-08T11:56:26.957162508+01:00 [torrust_tracker::bootstrap::logging][INFO] logging initialized.
2023-08-08T11:56:26.957931296+01:00 [torrust_tracker::bootstrap::jobs::tracker_apis][INFO] Starting Torrust APIs server on: http://127.0.0.1:1212
2023-08-08T11:56:26.958027355+01:00 [torrust_tracker::bootstrap::jobs::tracker_apis][INFO] Torrust APIs server started
```
@josecelano josecelano marked this pull request as ready for review August 8, 2023 11:15
@josecelano
Copy link
Member Author

josecelano commented Aug 8, 2023

There is a breaking change. I have removed the error when the default configuration is created:

Loading configuration from config file ./config.toml
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CreatedNewConfigHalt { location: Location { file: "packages/configuration/src/lib.rs", line: 520, col: 27 }, path: "./config.toml" }', src/bootstrap/app.rs:83:52
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Now the tracker continues running with the default configuration file:

Loading configuration from configuration file: `./config.toml` ...
Missing configuration file.
Creating a default configuration file: `./config.toml` ...
Please review the config file: `./config.toml` and restart the tracker if needed.
2023-08-08T12:16:24.548218890+01:00 [torrust_tracker::bootstrap::logging][INFO] logging initialized.
2023-08-08T12:16:24.548805484+01:00 [torrust_tracker::bootstrap::jobs::tracker_apis][INFO] Starting Torrust APIs server on: http://127.0.0.1:1212
2023-08-08T12:16:24.548882463+01:00 [torrust_tracker::bootstrap::jobs::tracker_apis][INFO] Torrust APIs server started

If we implement the issue to make the database optional and we make the no-database option the default one, we could run the tracker with default configuration (only memory) with a single docker command.

Alternatively, we could add a new env var TORRUST_TRACKER_USE_DEFAULT_CONFIG. If the env var is present, we do not even write the config file with the default config, we simply use the default config only in memory. What do you think @da2ce7?

@josecelano josecelano requested a review from da2ce7 August 8, 2023 11:38
@josecelano josecelano merged commit 3bc0a8c into torrust:develop Aug 9, 2023
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Improve docker UX
1 participant