Browse Source

add separate binaries for the server types

pbs
jake 4 years ago
parent
commit
7a831c35c4
  1. 25
      src/bin/login.rs
  2. 16
      src/bin/patch.rs
  3. 30
      src/bin/ship.rs

25
src/bin/login.rs

@ -0,0 +1,25 @@
use log::{info};
use elseware::entity::gateway::postgres::PostgresGateway;
use elseware::login::login::LoginServerState;
use elseware::login::character::CharacterServerState;
use elseware::common::mainloop::{login_mainloop, character_mainloop};
async fn main() {
let db_host = std::env::var("DB_HOST").unwrap();
let db_username = std::env::var("DB_USERNAME").unwrap();
let db_password = std::env::var("DB_PASSWORD").unwrap();
let db_dbname = std::env::var("DB_DBNAME").unwrap();
let entity_gateway = PostgresGateway::new(&db_host, &db_dbname, &db_username, &db_password);
let thread_entity_gateway = entity_gateway.clone();
let login_state = LoginServerState::new(thread_entity_gateway);
let login_loop = login_mainloop(login_state, elseware::login::login::LOGIN_PORT);
let char_state = CharacterServerState::new(entity_gateway);
let character_loop = character_mainloop(char_state, elseware::login::character::CHARACTER_PORT, elseware::login::login::COMMUNICATION_PORT);
info!("[auth/character] starting server");
async_std::task::block_on(async move {
futures::future::join_all(vec![login_loop, character_loop]).await
});
}

16
src/bin/patch.rs

@ -0,0 +1,16 @@
use elseware::patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd};
use log::{info};
use elseware::common::mainloop::patch_mainloop;
fn main() {
info!("[patch] starting server");
let patch_config = load_config();
let patch_motd = load_motd();
let (patch_file_tree, patch_file_lookup) = generate_patch_tree(patch_config.path.as_str());
let patch_state = PatchServerState::new(patch_file_tree, patch_file_lookup, patch_motd);
let patch_loop = patch_mainloop(patch_state, patch_config.port);
async_std::task::block_on(async move {
patch_loop.await
});
}

30
src/bin/ship.rs

@ -0,0 +1,30 @@
use log::{info};
use elseware::entity::gateway::postgres::PostgresGateway;
use elseware::ship::ship::ShipServerState;
use elseware::ship::ship::ShipServerStateBuilder;
use elseware::common::mainloop::ship_mainloop;
async fn main() {
let db_host = std::env::var("DB_HOST").unwrap();
let db_username = std::env::var("DB_USERNAME").unwrap();
let db_password = std::env::var("DB_PASSWORD").unwrap();
let db_dbname = std::env::var("DB_DBNAME").unwrap();
let entity_gateway = PostgresGateway::new(&db_host, &db_dbname, &db_username, &db_password);
let ship_name = std::env::var("SHIP_NAME").unwrap().parse().unwrap();
let ip = std::env::var("SELF_IP").unwrap().parse().unwrap();
let ship_state = ShipServerStateBuilder::new()
.name(ship_name)
.ip(ip)
.port(elseware::ship::ship::SHIP_PORT)
.gateway(entity_gateway)
.build();
let shipgate_ip = std::env::var("SHIPGATE_IP").unwrap().parse().unwrap();
let ship_loop = ship_mainloop(ship_state, elseware::ship::ship::SHIP_PORT, shipgate_ip, elseware::login::login::COMMUNICATION_PORT);
info!("[auth/character] starting server");
async_std::task::block_on(async move {
ship_loop.await
});
}
Loading…
Cancel
Save