Add SERVER_ID and PORT

This commit is contained in:
2024-06-29 21:45:38 -04:00
Unverified
parent 58b38f3d2d
commit 9ed9ae5078
4 changed files with 33 additions and 31 deletions

View File

@@ -65,7 +65,7 @@ async fn main() -> anyhow::Result<()> {
);"
).execute(&db_pool).await?;
let server_addr = (IpAddr::V6(Ipv6Addr::LOCALHOST), 5051);
let server_addr = (IpAddr::V6(Ipv6Addr::LOCALHOST), env::var("PORT").expect("PORT must be set").parse::<u16>().unwrap());
// JSON transport is provided by the json_transport tarpc module. It makes it easy
// to start up a serde-powered json serialization strategy over TCP.
@@ -81,7 +81,7 @@ async fn main() -> anyhow::Result<()> {
// serve is generated by the service attribute. It takes as input any type implementing
// the generated World trait.
.map(|channel| {
let server = RealmChatServer::new(channel.transport().peer_addr().unwrap(), db_pool.clone());
let server = RealmChatServer::new(env::var("SERVER_ID").expect("SERVER_ID must be set"), channel.transport().peer_addr().unwrap(), db_pool.clone());
channel.execute(server.serve()).for_each(spawn)
})
// Max 10 channels.