Kubernetes & Helm Charts #10
@@ -147,7 +147,7 @@ pub async fn serve_rest_api(
|
||||
.layer(cors);
|
||||
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("API_SERVICE_PORT").unwrap_or_else(|_| "8080".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "8080".to_string());
|
||||
let listener = tokio::net::TcpListener::bind(format!("{}:{}", addr, port))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -23,7 +23,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Set the gRPC server address
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("API_SERVICE_PORT").unwrap_or_else(|_| "8080".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "8080".to_string());
|
||||
|
||||
// Start health-check endpoint
|
||||
consul_registration::start_health_check(addr.as_str()).await?;
|
||||
|
||||
@@ -28,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Set the gRPC server address
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("AUTH_SERVICE_PORT").unwrap_or_else(|_| "50051".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "50051".to_string());
|
||||
let db_url = format!("http://{}",get_kube_service_endpoints_by_dns("database-service","tcp","database-service").await?.get(0).unwrap());
|
||||
let session_service_address = format!("http://{}",get_kube_service_endpoints_by_dns("session-service","tcp","session-service").await?.get(0).unwrap());
|
||||
|
||||
|
||||
@@ -8,12 +8,10 @@ use crate::character_db_client::CharacterDbClient;
|
||||
use crate::character_service::character::character_service_server::CharacterServiceServer;
|
||||
use crate::character_service::MyCharacterService;
|
||||
use dotenv::dotenv;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tracing::Level;
|
||||
use utils::consul_registration;
|
||||
use utils::service_discovery::{get_kube_service_endpoints_by_dns};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -28,7 +26,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Set the gRPC server address
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("CHARACTER_SERVICE_PORT").unwrap_or_else(|_| "50053".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "50053".to_string());
|
||||
let db_url = format!("http://{}",get_kube_service_endpoints_by_dns("database-service","tcp","database-service").await?.get(0).unwrap());
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ services:
|
||||
replicas: 1
|
||||
image: api-service:latest
|
||||
port: 8080
|
||||
env:
|
||||
SERVICE_PORT: 8080
|
||||
tcp:
|
||||
enabled: true
|
||||
portName: api-service
|
||||
@@ -33,6 +35,8 @@ services:
|
||||
replicas: 1
|
||||
image: auth-service:latest
|
||||
port: 50051
|
||||
env:
|
||||
SERVICE_PORT: 50051
|
||||
tcp:
|
||||
enabled: true
|
||||
portName: auth-service
|
||||
@@ -46,6 +50,8 @@ services:
|
||||
replicas: 1
|
||||
image: character-service:latest
|
||||
port: 50053
|
||||
env:
|
||||
SERVICE_PORT: 50053
|
||||
tcp:
|
||||
enabled: true
|
||||
portName: character-service
|
||||
@@ -59,6 +65,8 @@ services:
|
||||
replicas: 1
|
||||
image: database-service:latest
|
||||
port: 50052
|
||||
env:
|
||||
SERVICE_PORT: 50052
|
||||
tcp:
|
||||
enabled: true
|
||||
portName: database-service
|
||||
@@ -72,6 +80,8 @@ services:
|
||||
replicas: 1
|
||||
image: packet-service:latest
|
||||
port: 29000
|
||||
env:
|
||||
SERVICE_PORT: 29000
|
||||
tcp:
|
||||
enabled: true
|
||||
portName: game-packet-service
|
||||
@@ -85,6 +95,8 @@ services:
|
||||
replicas: 1
|
||||
image: session-service:latest
|
||||
port: 50055
|
||||
env:
|
||||
SERVICE_PORT: 50055
|
||||
tcp:
|
||||
enabled: true
|
||||
portName: session-service
|
||||
@@ -98,6 +110,8 @@ services:
|
||||
replicas: 1
|
||||
image: world-service:latest
|
||||
port: 50054
|
||||
env:
|
||||
SERVICE_PORT: 50054
|
||||
tcp:
|
||||
enabled: true
|
||||
portName: world-service
|
||||
|
||||
@@ -4,14 +4,13 @@ use database_service::grpc::database_service::MyDatabaseService;
|
||||
use database_service::grpc::user_service_server::UserServiceServer;
|
||||
use dotenv::dotenv;
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::net::SocketAddr;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use tonic::transport::Server;
|
||||
use tracing::{info, Level};
|
||||
use utils::consul_registration;
|
||||
use utils::redis_cache::RedisCache;
|
||||
|
||||
#[tokio::main]
|
||||
@@ -25,13 +24,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.init();
|
||||
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("DATABASE_SERVICE_PORT").unwrap_or_else(|_| "50052".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "50052".to_string());
|
||||
|
||||
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
let redis_url = env::var("REDIS_URL").unwrap_or_else(|_| "redis://127.0.0.1:6379".to_string());
|
||||
|
||||
let full_addr = format!("{}:{}", &addr, port);
|
||||
let address = full_addr.parse().expect("Invalid address");
|
||||
let pool = PgPoolOptions::new()
|
||||
.max_connections(5)
|
||||
.connect(&database_url)
|
||||
@@ -45,8 +42,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let (mut health_reporter, health_service) = tonic_health::server::health_reporter();
|
||||
health_reporter.set_serving::<UserServiceServer<MyDatabaseService>>().await;
|
||||
|
||||
// Pass `shared_cache` into services as needed
|
||||
info!("Database Service running on {}", address);
|
||||
let address = SocketAddr::new(addr.parse()?, port.parse()?);
|
||||
tokio::spawn(
|
||||
Server::builder()
|
||||
.add_service(health_service)
|
||||
@@ -54,6 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.add_service(CharacterDbServiceServer::new(my_service))
|
||||
.serve(address),
|
||||
);
|
||||
info!("Database Service running on {}", address);
|
||||
|
||||
utils::signal_handler::wait_for_signal().await;
|
||||
Ok(())
|
||||
|
||||
@@ -67,7 +67,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Set the gRPC server address
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("PACKET_SERVICE_PORT").unwrap_or_else(|_| "4000".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "29000".to_string());
|
||||
let metrics_port = env::var("PACKET_METRICS_PORT").unwrap_or_else(|_| "4001".to_string());
|
||||
let auth_url = format!("http://{}",get_kube_service_endpoints_by_dns("auth-service","tcp","auth-service").await?.get(0).unwrap());
|
||||
let character_url = format!("http://{}",get_kube_service_endpoints_by_dns("character-service","tcp","character-service").await?.get(0).unwrap());
|
||||
|
||||
@@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Set the gRPC server address
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("SESSION_SERVICE_PORT").unwrap_or_else(|_| "50055".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "50055".to_string());
|
||||
let redis_url = env::var("REDIS_URL").unwrap_or_else(|_| "redis://127.0.0.1:6379".to_string());
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Set the gRPC server address
|
||||
let addr = env::var("LISTEN_ADDR").unwrap_or_else(|_| "0.0.0.0".to_string());
|
||||
let port = env::var("WORLD_SERVICE_PORT").unwrap_or_else(|_| "50054".to_string());
|
||||
let port = env::var("SERVICE_PORT").unwrap_or_else(|_| "50054".to_string());
|
||||
let db_url = format!("http://{}",get_kube_service_endpoints_by_dns("database-service","tcp","database-service").await?.get(0).unwrap());
|
||||
|
||||
// Register service with Consul
|
||||
|
||||
Reference in New Issue
Block a user