Add Linux compatibility for LoginServer
- Updated main.cpp with platform-specific code for Windows/Linux - Modified stdafx.h to include Linux headers and definitions - Updated signal_handler.cpp for cross-platform signal handling - Added Linux-compatible types and macros - Created CMakeLists.txt for Linux build system - Added build.sh script for automated building - Added loginserver.sh script for server management - Created comprehensive README_LINUX.md with deployment instructions - All changes maintain Windows compatibility using preprocessor directives
This commit is contained in:
@@ -0,0 +1,295 @@
|
||||
# Knight Online Login Server - Linux Version
|
||||
|
||||
This directory contains the Linux-compatible version of the Knight Online Login Server.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before building and running the Login Server on Linux, make sure you have the following dependencies installed:
|
||||
|
||||
### Ubuntu/Debian
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential cmake g++ unixodbc-dev
|
||||
```
|
||||
|
||||
### CentOS/RHEL/Fedora
|
||||
```bash
|
||||
# CentOS/RHEL
|
||||
sudo yum groupinstall "Development Tools"
|
||||
sudo yum install cmake unixODBC-devel
|
||||
|
||||
# Fedora
|
||||
sudo dnf groupinstall "Development Tools"
|
||||
sudo dnf install cmake unixODBC-devel
|
||||
```
|
||||
|
||||
## Building the Server
|
||||
|
||||
### Quick Start
|
||||
```bash
|
||||
# Make build script executable
|
||||
chmod +x build.sh
|
||||
|
||||
# Build everything
|
||||
./build.sh all
|
||||
```
|
||||
|
||||
### Manual Build Steps
|
||||
```bash
|
||||
# 1. Make scripts executable
|
||||
chmod +x build.sh loginserver.sh
|
||||
|
||||
# 2. Build the project
|
||||
./build.sh build
|
||||
|
||||
# 3. Install binaries
|
||||
./build.sh install
|
||||
```
|
||||
|
||||
### Build Options
|
||||
```bash
|
||||
./build.sh clean # Clean build files
|
||||
./build.sh build # Build project
|
||||
./build.sh rebuild # Clean and build
|
||||
./build.sh install # Install binaries
|
||||
./build.sh all # Full build and install
|
||||
./build.sh -j 4 build # Build with 4 parallel jobs
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Database Setup
|
||||
1. Install and configure your ODBC driver for your database
|
||||
2. Edit `LogIn.ini` with your database connection details:
|
||||
|
||||
```ini
|
||||
[ODBC]
|
||||
DSN=KO_MAIN
|
||||
UID=your_username
|
||||
PWD=your_password
|
||||
```
|
||||
|
||||
### Server Configuration
|
||||
Edit `LogIn.ini` to configure server settings:
|
||||
|
||||
```ini
|
||||
[SETTINGS]
|
||||
PORT=15100
|
||||
|
||||
[SERVER_LIST]
|
||||
COUNT=1
|
||||
SERVER_00=192.168.1.104
|
||||
LANIP_00=192.168.1.104
|
||||
NAME_00=Your Server Name
|
||||
ID_00=1
|
||||
```
|
||||
|
||||
## Running the Server
|
||||
|
||||
### Start the Server
|
||||
```bash
|
||||
./loginserver.sh start
|
||||
```
|
||||
|
||||
### Check Server Status
|
||||
```bash
|
||||
./loginserver.sh status
|
||||
```
|
||||
|
||||
### View Server Logs
|
||||
```bash
|
||||
./loginserver.sh logs
|
||||
```
|
||||
|
||||
### Stop the Server
|
||||
```bash
|
||||
./loginserver.sh stop
|
||||
```
|
||||
|
||||
### Restart the Server
|
||||
```bash
|
||||
./loginserver.sh restart
|
||||
```
|
||||
|
||||
## Management Commands
|
||||
|
||||
The `loginserver.sh` script provides several management commands:
|
||||
|
||||
- `start` - Start the login server
|
||||
- `stop` - Stop the login server
|
||||
- `restart` - Restart the login server
|
||||
- `status` - Show server status and process information
|
||||
- `logs` - View server logs in real-time
|
||||
- `config` - Create default configuration file
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
LoginServer/
|
||||
├── bin/ # Compiled binaries
|
||||
│ └── LoginServer # Main server executable
|
||||
├── build/ # CMake build directory
|
||||
├── Logs/ # Server log files
|
||||
│ ├── LoginServer.log # Main server log
|
||||
│ ├── Login_DD_MM_YYYY.log # Daily user login log
|
||||
│ └── server_output.log # Server console output
|
||||
├── build.sh # Build script
|
||||
├── loginserver.sh # Server management script
|
||||
├── LogIn.ini # Server configuration
|
||||
├── CMakeLists.txt # CMake configuration
|
||||
└── README_LINUX.md # This file
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### 1. Build Failures
|
||||
- Make sure all dependencies are installed
|
||||
- Check that you have sufficient permissions
|
||||
- Verify CMake version (3.10 or higher required)
|
||||
|
||||
#### 2. ODBC Connection Issues
|
||||
```bash
|
||||
# Test ODBC connection
|
||||
isql -v DSN_NAME username password
|
||||
|
||||
# List available ODBC drivers
|
||||
odbcinst -q -d
|
||||
|
||||
# List configured DSNs
|
||||
odbcinst -q -s
|
||||
```
|
||||
|
||||
#### 3. Permission Issues
|
||||
```bash
|
||||
# Make scripts executable
|
||||
chmod +x build.sh loginserver.sh
|
||||
|
||||
# Check binary permissions
|
||||
chmod +x bin/LoginServer
|
||||
```
|
||||
|
||||
#### 4. Port Already in Use
|
||||
```bash
|
||||
# Check what's using the port
|
||||
sudo netstat -tlnp | grep :15100
|
||||
|
||||
# Kill process using the port
|
||||
sudo kill -9 PID
|
||||
```
|
||||
|
||||
### Debugging
|
||||
|
||||
#### Enable Debug Mode
|
||||
Edit CMakeLists.txt and add debug flags:
|
||||
```cmake
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DDEBUG")
|
||||
```
|
||||
|
||||
#### Run with GDB
|
||||
```bash
|
||||
gdb ./bin/LoginServer
|
||||
(gdb) run
|
||||
```
|
||||
|
||||
#### Monitor System Resources
|
||||
```bash
|
||||
# Monitor server process
|
||||
top -p $(cat loginserver.pid)
|
||||
|
||||
# Check memory usage
|
||||
cat /proc/$(cat loginserver.pid)/status
|
||||
|
||||
# Monitor network connections
|
||||
ss -tlnp | grep LoginServer
|
||||
```
|
||||
|
||||
## Security Considerations
|
||||
|
||||
1. **Firewall Configuration**
|
||||
```bash
|
||||
# Allow login server port
|
||||
sudo ufw allow 15100/tcp
|
||||
```
|
||||
|
||||
2. **User Permissions**
|
||||
- Run the server as a non-root user
|
||||
- Set appropriate file permissions
|
||||
- Use a dedicated service user
|
||||
|
||||
3. **Database Security**
|
||||
- Use strong database passwords
|
||||
- Limit database user permissions
|
||||
- Enable database connection encryption
|
||||
|
||||
## Integration with Gitea
|
||||
|
||||
This server is configured to work with the Gitea repository at:
|
||||
- Local: `http://192.168.1.104:3000/`
|
||||
- SSH: `ssh://gitea@192.168.1.104:2222/leventferrah/knightonline.git`
|
||||
|
||||
### Deployment Workflow
|
||||
```bash
|
||||
# Pull latest changes
|
||||
git pull knight main
|
||||
|
||||
# Build and deploy
|
||||
./build.sh all
|
||||
|
||||
# Restart server
|
||||
./loginserver.sh restart
|
||||
```
|
||||
|
||||
## Performance Tuning
|
||||
|
||||
### System Limits
|
||||
Edit `/etc/security/limits.conf`:
|
||||
```
|
||||
username soft nofile 65536
|
||||
username hard nofile 65536
|
||||
```
|
||||
|
||||
### Network Optimization
|
||||
Edit `/etc/sysctl.conf`:
|
||||
```
|
||||
net.core.somaxconn = 1024
|
||||
net.ipv4.tcp_max_syn_backlog = 1024
|
||||
```
|
||||
|
||||
## Monitoring
|
||||
|
||||
### Log Monitoring
|
||||
```bash
|
||||
# Monitor all logs
|
||||
tail -f Logs/*.log
|
||||
|
||||
# Monitor specific log
|
||||
tail -f Logs/LoginServer.log
|
||||
```
|
||||
|
||||
### Process Monitoring
|
||||
```bash
|
||||
# Check if server is running
|
||||
./loginserver.sh status
|
||||
|
||||
# Monitor resource usage
|
||||
watch -n 1 './loginserver.sh status'
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
For issues and support:
|
||||
- Check the server logs in `Logs/` directory
|
||||
- Verify configuration in `LogIn.ini`
|
||||
- Test database connectivity
|
||||
- Check network connectivity and firewall settings
|
||||
|
||||
## Version Information
|
||||
|
||||
- **Server Version**: Knight Online Login Server v1.0
|
||||
- **Platform**: Linux (Ubuntu/CentOS/Debian compatible)
|
||||
- **Build System**: CMake 3.10+
|
||||
- **Compiler**: GCC 7+
|
||||
- **Dependencies**: ODBC, pthread
|
||||
Reference in New Issue
Block a user