-
Notifications
You must be signed in to change notification settings - Fork 5
refactor: introduce statefull sub-modules #44
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
Conversation
4aca0f3
to
2cf243d
Compare
src/common.rs
Outdated
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) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Signed-off-by: Jan Zachmann <[email protected]>
This reverts commit fd9c85d.
Api
,OmnectDeviceServiceClient
andSocketClient