Skip to main content

Overview

GamePanelX V3 provides two core scripts for managing server lifecycle:
  • Restart - Starts or restarts a server
  • Stop - Stops a running server
Both scripts use GNU Screen for console access and support advanced features like CPU pinning and process monitoring.

Restarting Servers

The Restart script is located at ~/_SERVERS/scripts/Restart and handles both starting and restarting servers.

Basic Usage

./Restart -u user123 -i 192.168.10.10 -p 27015 \
  -w orangebox \
  -o './srcds_run -game cstrike +ip 192.168.10.10 -port 27015 +map de_dust2 +maxplayers 12'

Command-Line Parameters

-u
string
required
UsernameClient’s GPX username for the server account.
-i
string
required
IP AddressServer IP address (e.g., 192.168.10.10).
-p
string
required
PortServer port number (e.g., 27015).
-o
string
required
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'
-P
string
PID FileServer PID filename (optional). Use local paths only, such as some/dir/run.pid, not absolute paths.
-w
string
Working DirectoryServer working directory to CD into before startup. Use local paths only (relative to server directory).
-s
string
Unsuspend ServerSet to yes to unsuspend a suspended server before starting.
-c
string
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.
-l
string
GPX LoggingEnable GPX logging features (internal use).

Restart Process Flow

1

Validation

Validates required parameters and checks if the server directory exists at ~/accounts/{username}/{ip}.{port}.
2

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.
3

Stop Running Server

If a server is currently running (checked via .gpxpid file), calls the Stop script to terminate it cleanly.
4

Change Directory

Changes to the working directory if -w is specified, otherwise uses the server root directory.
5

Start Server

Launches the server using GNU Screen (if available) or as a background process:With GNU Screen:
screen -d -m -S "{ip}.{port}" {command_line}
Without GNU Screen:
{command_line} 2>&1 > .gpxsrv.log &
6

PID Tracking

Saves the process ID to .gpxpid and optionally copies the server’s own PID file if -P is specified.
7

Monitoring Loop

Forks a monitoring loop that checks every 3 seconds if the server has crashed and automatically restarts it.

Stopping Servers

The Stop script is located at ~/_SERVERS/scripts/Stop and handles graceful server shutdown.

Basic Usage

./Stop -u user123 -i 192.168.10.10 -p 27015

Command-Line Parameters

-u
string
required
UsernameClient’s GPX username for the server account.
-i
string
required
IP AddressServer IP address.
-p
string
required
PortServer port number.
-s
string
Suspend ServerSet to yes to suspend the server (moves directory to hidden location) instead of just stopping it.
-r
string
Restart PIDPID of the “Restart” script (internal use). Used when Restart calls Stop to avoid killing itself.
-w
string
Working DirectoryServer working directory (internal use).
-P
string
Server PID FilePath to the server’s own PID file, if it maintains one.
-d
string
Debug ModeEnable debug output for troubleshooting.

Stop Process Flow

1

Validation

Validates required parameters and checks if the server directory exists.
2

Kill Restart Script

Terminates the monitoring loop from the Restart script (if running) by reading .gpxrespid.
3

Kill GNU Screen

If the server is running in GNU Screen, quits the screen session:
screen -d -S "{ip}.{port}" -X quit
4

Kill Server Processes

Terminates all server processes by:
  1. Killing the main PID from .gpxpid
  2. Killing child processes
  3. Killing any processes matching the IP and port (fallback)
5

Kill Update Processes

If an update is in progress (.gpxupdatepid exists), terminates all update-related processes.
6

Clean Up PID Files

Removes .gpxpid, .gpxrespid, and .gpxscreen.pid files.
7

Suspend (Optional)

If -s yes is specified, moves the server directory to a hidden location:
mv ~/accounts/{username}/{ip}.{port} ~/accounts/{username}/.{ip}.{port}

Process Tracking

GamePanelX uses several PID files to track running processes:
FilePurpose
.gpxpidMain server process ID
.gpxrespidRestart script monitoring loop PID
.gpxscreen.pidGNU Screen session PID
.gpxupdatepidServer 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
The Restart script automatically detects and uses GNU Screen if available. It searches for screen in:
  • /usr/bin/screen
  • /usr/sbin/screen
  • /sbin/screen
  • /usr/local/bin/screen
  • /usr/local/sbin/screen
If GNU Screen is not found, the script will still start servers but console access will be limited. Output is redirected to .gpxsrv.log.

Accessing Server Console

To attach to a running server’s console:
screen -r {ip}.{port}
To detach without stopping the server:
Ctrl+A, then D

CPU Pinning with Taskset

Pin a server to specific CPU cores for performance optimization:
./Restart -u user123 -i 192.168.10.10 -p 27015 \
  -c 0-3 \
  -o './srcds_run -game cstrike +ip 192.168.10.10 -port 27015'
This pins the server to CPU cores 0 through 3.
The taskset command must be available on the system. The script will exit with an error if taskset is specified but not installed.

Automatic Restart on Crash

The Restart script includes built-in crash detection and automatic recovery:
  1. After starting a server, the script forks a monitoring loop
  2. The loop checks every 3 seconds if the server process is still running
  3. If the server crashes, it’s automatically restarted with the same parameters
  4. This continues until the Stop script is called
The monitoring loop PID is saved to .gpxrespid.

Examples

# Start a Counter-Strike: Source server
./Restart -u player1 -i 192.168.1.100 -p 27015 \
  -w orangebox \
  -o './srcds_run -game cstrike -ip 192.168.1.100 -port 27015 +map de_dust2'

Suspending Servers

Suspension allows you to temporarily disable a server without deleting it:
# Suspend a server
./Stop -u user123 -i 192.168.10.10 -p 27015 -s yes
This moves the directory from:
~/accounts/{username}/{ip}.{port}
To:
~/accounts/{username}/.{ip}.{port}
To unsuspend and start:
./Restart -u user123 -i 192.168.10.10 -p 27015 -s yes -o '{command}'

Error Handling

Common Issues:
  • Directory not found: Server directory doesn’t exist at expected location
  • Working directory error: Specified -w path doesn’t exist within server directory
  • No GNU Screen: Warning logged but server still starts (without console access)
  • Screen startup failure: Check command line syntax and permissions
All operations are logged to ~/logs/servers.log with timestamps and hostnames.

Best Practices

  1. Always Use Screen: Install GNU Screen for better server management
  2. Test Command Lines: Validate command lines manually before using in scripts
  3. Monitor Logs: Check ~/logs/servers.log for detailed status information
  4. Use Working Directories: Specify -w when servers need to run from subdirectories
  5. Graceful Stops: Use the Stop script instead of killing processes manually
  6. CPU Pinning: Use -c flag for performance-critical servers on multi-core systems

Build docs developers (and LLMs) love