[Add] port options in nix flake
This commit is contained in:
parent
505acd4b23
commit
6cc29a137e
3 changed files with 48 additions and 4 deletions
|
|
@ -39,9 +39,14 @@ async fn main() {
|
|||
dotenv().ok();
|
||||
startup();
|
||||
|
||||
let rho_port = env::var("RHO_PORT")
|
||||
.ok()
|
||||
.and_then(|s| s.parse().ok())
|
||||
.unwrap_or(959);
|
||||
|
||||
get_omega_connection();
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = start(959).await {
|
||||
if let Err(e) = start(rho_port).await {
|
||||
log_err!(0, util::logger::PrintType::General, "{}", e);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,6 +26,20 @@ use uuid::Uuid;
|
|||
|
||||
const OMEGA_HOST_DEFAULT: &str = "tensamin.net";
|
||||
const OMEGA_PORT_DEFAULT: u16 = 9187;
|
||||
|
||||
fn omega_host_and_port() -> (String, u16) {
|
||||
let host = env::var("OMEGA_HOST")
|
||||
.map(|s| s.trim().to_string())
|
||||
.unwrap_or_else(|_| OMEGA_HOST_DEFAULT.to_string());
|
||||
|
||||
let port = env::var("OMEGA_PORT")
|
||||
.ok()
|
||||
.and_then(|s| s.trim().parse().ok())
|
||||
.unwrap_or(OMEGA_PORT_DEFAULT);
|
||||
|
||||
(host, port)
|
||||
}
|
||||
|
||||
const RECONNECT_DELAY: Duration = Duration::from_secs(5);
|
||||
const MAX_RECONNECT_DELAY: Duration = Duration::from_secs(300);
|
||||
const CONNECTION_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
|
@ -104,7 +118,8 @@ pub struct OmegaConnection {
|
|||
|
||||
impl OmegaConnection {
|
||||
pub fn new() -> Self {
|
||||
Self::with_host(OMEGA_HOST_DEFAULT, OMEGA_PORT_DEFAULT)
|
||||
let (host, port) = omega_host_and_port();
|
||||
Self::with_host(&host, port)
|
||||
}
|
||||
|
||||
pub fn with_host(host: &str, port: u16) -> Self {
|
||||
|
|
|
|||
Loading…
Reference in a new issue