Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo check --all-targets --workspace --all-features
- run: cargo check --workspace --all-targets
- run: cargo check --workspace --all-targets --no-default-features
- run: cargo check --workspace --all-targets --all-features

clippy:
runs-on: ubuntu-latest
Expand All @@ -18,7 +20,9 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- run: cargo clippy --all-targets --workspace --all-features
- run: cargo clippy --workspace --all-targets
- run: cargo clippy --workspace --all-targets --no-default-features
- run: cargo clippy --workspace --all-targets --all-features

rustfmt:
runs-on: ubuntu-latest
Expand All @@ -44,7 +48,9 @@ jobs:
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.76.0"
- run: cargo check --all-targets --workspace --all-features
- run: cargo check --workspace --all-targets
- run: cargo check --workspace --all-targets --no-default-features
- run: cargo check --workspace --all-targets --all-features

check-deny:
runs-on: ubuntu-latest
Expand All @@ -70,7 +76,7 @@ jobs:
strip: true
- run: |
mkdir -p staging/ artifacts/
cp master/config/default.toml staging/config.toml
cp crates/xash3d-master/config/default.toml staging/config.toml
find target/${{ matrix.platform.target }}/release -maxdepth 1 -type f -executable -exec cp {} staging/ ';'
pushd staging/
tar --zstd -cvf ../artifacts/xash3d-master-${{ matrix.platform.target }}.tar.zst *
Expand Down
25 changes: 15 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
[workspace]
resolver = "2"
members = [
"protocol",
"master",
"admin",
"query",
"observer",
]
default-members = ["master", "protocol"]
members = ["crates/*"]

[workspace.package]
authors = ["Denis Drakhnia <numas13@gmail.com>"]
Expand All @@ -16,16 +9,28 @@ homepage = "https://xash.su"
repository = "https://github.com/FWGS/xash3d-master"

[workspace.dependencies]
xash3d-protocol = { path = "protocol", version = "0.2.0", features = ["net"] }
xash3d-observer = { path = "observer", version = "0.1.0" }
#
# Workspace crates
#
xash3d-protocol = { path = "crates/xash3d-protocol", version = "0.2.0", features = ["net"] }
xash3d-observer = { path = "crates/xash3d-observer", version = "0.1.0" }

#
# External crates
#
libc = "0.2.148"
log = "0.4"
bitflags = "2.4"
thiserror = "2"
getopts = "0.2.21"
blake2b_simd = "1.0"
fastrand = "2"
ahash = "0.8"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
toml = "1.0"
crossterm = { version = "0.29", default-features = false, features = ["events", "bracketed-paste", "windows"] }
signal-hook = { version = "0.3.17", default-features = false }

[profile.release]
codegen-units = 1
Expand Down
232 changes: 0 additions & 232 deletions admin/LICENSE

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions crates/xash3d-admin/LICENSE-GPL-3.0.txt
3 changes: 0 additions & 3 deletions admin/src/cli.rs → crates/xash3d-admin/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: 2023 Denis Drakhnia <numas13@gmail.com>

use std::process;

use getopts::Options;
Expand Down
3 changes: 0 additions & 3 deletions admin/src/main.rs → crates/xash3d-admin/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: 2023 Denis Drakhnia <numas13@gmail.com>

mod cli;

use std::env;
Expand Down
14 changes: 4 additions & 10 deletions master/Cargo.toml → crates/xash3d-master/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "xash3d-master"
description = "Master server for games on Xash3D engine"
version = "0.2.1"
license = "LGPL-3.0-only"
license = "AGPL-3.0-only"
keywords = ["xash3d"]
categories = ["command-line-utilities"]
authors.workspace = true
Expand All @@ -17,21 +17,15 @@ default = ["logtime"]
logtime = []
stats = []

[[bin]]
name = "xash3d-master"
path = "bin/main.rs"

[dependencies]
thiserror.workspace = true
getopts.workspace = true
log.workspace = true
bitflags.workspace = true
fastrand.workspace = true
serde.workspace = true
toml = "1.0"
toml.workspace = true
blake2b_simd.workspace = true
ahash = "0.8"
ahash.workspace = true
signal-hook.workspace = true
xash3d-protocol.workspace = true

[target.'cfg(not(windows))'.dependencies]
signal-hook = { version = "0.3.17", default-features = false }
1 change: 1 addition & 0 deletions crates/xash3d-master/LICENSE-AGPL-3.0.txt
File renamed without changes.
4 changes: 1 addition & 3 deletions master/bin/cli.rs → crates/xash3d-master/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only

use std::net::IpAddr;
use std::process;

use getopts::Options;
use log::LevelFilter;
use thiserror::Error;

use xash3d_master::config;
use crate::config;

const BIN_NAME: &str = env!("CARGO_BIN_NAME");
const PKG_NAME: &str = env!("CARGO_PKG_NAME");
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions master/bin/logger.rs → crates/xash3d-master/src/logger.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only

use std::sync::atomic::{AtomicBool, Ordering};

use log::{Metadata, Record};
use xash3d_master::config::LogConfig;

use crate::config::LogConfig;

pub struct Logger {
print_time: AtomicBool,
Expand Down
58 changes: 30 additions & 28 deletions master/bin/main.rs → crates/xash3d-master/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
// SPDX-License-Identifier: GPL-3.0-only

#![deny(unsafe_code)]

#[macro_use]
extern crate log;

mod cli;
mod config;
mod hash_map;
mod logger;

use std::{
process,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
};

use log::{error, info};
#[cfg(not(windows))]
use signal_hook::{consts::signal::*, flag as signal_flag};
use xash3d_master::{
config::{self, Config},
Error, Master,
mod master_server;
mod periodic;
mod signal_flags;
mod stats;
mod str_arr;
mod time;

use std::process;

use crate::{
cli::Cli,
config::Config,
logger::Logger,
master_server::{Error, Master},
signal_flags::SignalFlags,
stats::Stats,
str_arr::StrArr,
};

use crate::{cli::Cli, logger::Logger};

fn load_config(cli: &Cli, logger: &Logger) -> Result<Config, config::Error> {
let mut cfg = match cli.config_path {
Some(ref p) => config::load(p.as_ref())?,
Expand Down Expand Up @@ -53,7 +56,7 @@ fn load_config(cli: &Cli, logger: &Logger) -> Result<Config, config::Error> {
fn run() -> Result<(), Error> {
let cli = cli::parse().unwrap_or_else(|e| {
eprintln!("{e}");
std::process::exit(1);
process::exit(1);
});

let logger = logger::init();
Expand All @@ -67,15 +70,11 @@ fn run() -> Result<(), Error> {
});

let mut master = Master::new(cfg)?;
let sig_flag = Arc::new(AtomicBool::new(false));
// XXX: Windows does not support SIGUSR1.
#[cfg(not(windows))]
signal_flag::register(SIGUSR1, sig_flag.clone())?;
let sig_flags = SignalFlags::init()?;
while !sig_flags.is_exit() {
master.run()?;

loop {
master.run(&sig_flag)?;

if sig_flag.swap(false, Ordering::Relaxed) {
if sig_flags.remove_reload() {
if let Some(config_path) = cli.config_path.as_deref() {
info!("Reloading config from {}", config_path);

Expand All @@ -90,6 +89,9 @@ fn run() -> Result<(), Error> {
}
}
}

info!("Server stopped");
Ok(())
}

fn main() {
Expand Down
Loading
Loading