Overview
GamePanelX V3 provides two core scripts for managing server lifecycle:- Restart - Starts or restarts a server
- Stop - Stops a running server
Restarting Servers
TheRestart script is located at ~/_SERVERS/scripts/Restart and handles both starting and restarting servers.
Basic Usage
Command-Line Parameters
UsernameClient’s GPX username for the server account.
IP AddressServer IP address (e.g.,
192.168.10.10).PortServer port number (e.g.,
27015).Command LineComplete command-line to execute. Must be provided in quotes if it contains spaces.Example:
'./srcds_run -game cstrike +ip 192.168.10.10 -port 27015 +map de_dust2'PID FileServer PID filename (optional). Use local paths only, such as
some/dir/run.pid, not absolute paths.Working DirectoryServer working directory to CD into before startup. Use local paths only (relative to server directory).
Unsuspend ServerSet to
yes to unsuspend a suspended server before starting.Taskset CPUCPU number/core to pin the server process to using
taskset (optional).Example: -c 0 pins to CPU core 0, -c 0-3 pins to cores 0 through 3.GPX LoggingEnable GPX logging features (internal use).
Restart Process Flow
Validation
Validates required parameters and checks if the server directory exists at
~/accounts/{username}/{ip}.{port}.Unsuspend (Optional)
If
-s yes is specified and a suspended directory exists at ~/accounts/{username}/.{ip}.{port}, it’s moved back to the active location.Stop Running Server
If a server is currently running (checked via
.gpxpid file), calls the Stop script to terminate it cleanly.Change Directory
Changes to the working directory if
-w is specified, otherwise uses the server root directory.Start Server
Launches the server using GNU Screen (if available) or as a background process:With GNU Screen:Without GNU Screen:
PID Tracking
Saves the process ID to
.gpxpid and optionally copies the server’s own PID file if -P is specified.Stopping Servers
TheStop script is located at ~/_SERVERS/scripts/Stop and handles graceful server shutdown.
Basic Usage
Command-Line Parameters
UsernameClient’s GPX username for the server account.
IP AddressServer IP address.
PortServer port number.
Suspend ServerSet to
yes to suspend the server (moves directory to hidden location) instead of just stopping it.Restart PIDPID of the “Restart” script (internal use). Used when Restart calls Stop to avoid killing itself.
Working DirectoryServer working directory (internal use).
Server PID FilePath to the server’s own PID file, if it maintains one.
Debug ModeEnable debug output for troubleshooting.
Stop Process Flow
Kill Restart Script
Terminates the monitoring loop from the Restart script (if running) by reading
.gpxrespid.Kill Server Processes
Terminates all server processes by:
- Killing the main PID from
.gpxpid - Killing child processes
- Killing any processes matching the IP and port (fallback)
Kill Update Processes
If an update is in progress (
.gpxupdatepid exists), terminates all update-related processes.Process Tracking
GamePanelX uses several PID files to track running processes:| File | Purpose |
|---|---|
.gpxpid | Main server process ID |
.gpxrespid | Restart script monitoring loop PID |
.gpxscreen.pid | GNU Screen session PID |
.gpxupdatepid | Server update process PID |
GNU Screen Support
GNU Screen is highly recommended for production use. It enables:
- Interactive console access
- Server output viewing
- Command injection to running servers
/usr/bin/screen/usr/sbin/screen/sbin/screen/usr/local/bin/screen/usr/local/sbin/screen
Accessing Server Console
To attach to a running server’s console:CPU Pinning with Taskset
Pin a server to specific CPU cores for performance optimization:Automatic Restart on Crash
The Restart script includes built-in crash detection and automatic recovery:- After starting a server, the script forks a monitoring loop
- The loop checks every 3 seconds if the server process is still running
- If the server crashes, it’s automatically restarted with the same parameters
- This continues until the Stop script is called
.gpxrespid.
Examples
Suspending Servers
Suspension allows you to temporarily disable a server without deleting it:Error Handling
All operations are logged to
~/logs/servers.log with timestamps and hostnames.Best Practices
- Always Use Screen: Install GNU Screen for better server management
- Test Command Lines: Validate command lines manually before using in scripts
- Monitor Logs: Check
~/logs/servers.logfor detailed status information - Use Working Directories: Specify
-wwhen servers need to run from subdirectories - Graceful Stops: Use the Stop script instead of killing processes manually
- CPU Pinning: Use
-cflag for performance-critical servers on multi-core systems
Related Scripts
- Creating Servers - Initial server creation and deployment
- Updating Servers - Updating game server files
- Working with Templates - Template management