refactor: introduce statefull sub-modules#44
Merged
JanZachmann merged 1 commit intoomnect:mainfrom May 28, 2025
Merged
Conversation
JanZachmann
commented
May 21, 2025
4aca0f3 to
2cf243d
Compare
empwilli
approved these changes
May 26, 2025
src/common.rs
Outdated
Comment on lines
24
to
35
| let port = var("CENTRIFUGO_HTTP_SERVER_PORT").unwrap_or({ | ||
| // TODO: Audit that the environment access only happens in single-threaded code. | ||
| unsafe { set_var("CENTRIFUGO_HTTP_SERVER_PORT", "8000") }; | ||
| "8000".to_string() | ||
| }); | ||
| let client_token = Uuid::new_v4().to_string(); | ||
| let api_key = Uuid::new_v4().to_string(); | ||
|
|
||
| // TODO: Audit that the environment access only happens in single-threaded code. | ||
| unsafe { set_var("CENTRIFUGO_CLIENT_TOKEN_HMAC_SECRET_KEY", &client_token) }; | ||
| // TODO: Audit that the environment access only happens in single-threaded code. | ||
| unsafe { set_var("CENTRIFUGO_HTTP_API_KEY", &api_key) }; |
Contributor
There was a problem hiding this comment.
IMHO we should explicitly launch centrifugo with the environment variables taken from CENTRIFUGO_CONFIG. Then we don't have to poison the environment of the running parent process (which could lead to complexities in testing down the line).
src/main.rs
Outdated
Comment on lines
286
to
226
|
|
||
| std::env::set_var("CENTRIFUGO_HTTP_SERVER_TLS_CERT_PEM", cert_path!()); | ||
| std::env::set_var("CENTRIFUGO_HTTP_SERVER_TLS_KEY_PEM", key_path!()); | ||
| // TODO: Audit that the environment access only happens in single-threaded code. | ||
| unsafe { | ||
| std::env::set_var( | ||
| "CENTRIFUGO_HTTP_SERVER_TLS_CERT_PEM", | ||
| certificate::cert_path(), | ||
| ) | ||
| }; | ||
| // TODO: Audit that the environment access only happens in single-threaded code. | ||
| unsafe { | ||
| std::env::set_var( | ||
| "CENTRIFUGO_HTTP_SERVER_TLS_KEY_PEM", | ||
| certificate::key_path(), | ||
| ) | ||
| }; | ||
|
|
||
| let mut centrifugo = | ||
| Command::new(std::fs::canonicalize("centrifugo").expect("centrifugo not found")) |
Contributor
There was a problem hiding this comment.
IMHO we should launch Command with env (https://doc.rust-lang.org/std/process/struct.Command.html#method.env), this way the environment of our omnect-ui stays clean, we don't have to use unsafe, and we don't run in sketchy edge cases with threading.
ronny-standtke
approved these changes
May 27, 2025
Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
JoergZeidler
approved these changes
May 28, 2025
JanZachmann
added a commit
that referenced
this pull request
May 28, 2025
This reverts commit fd9c85d.
JanZachmann
added a commit
that referenced
this pull request
May 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Api,OmnectDeviceServiceClientandSocketClient