كيفية تثبيت خادم FiveM: دليل خطوة بخطوة
دليل شامل لتثبيت خادم FiveM على REXE VDS: إعداد txAdmin، إعدادات المنافذ وتحسين الأداء لخوادم GTA V Roleplay. ابدأ خادمك في دقائق.
تشغيل خادم الألعاب تلقائياً مع systemd، سكريبتات watchdog، سياسات إعادة التشغيل واستخدام tmux/screen.
Game servers are services that need to run 24/7. Automatic restart in case of server crashes, system reboots, or unexpected errors is critical. This guide covers systemd service configuration, watchdog scripts, tmux/screen usage, and restart policy settings in detail.
sudo nano /etc/systemd/system/gameserver.service
[Unit]
Description=Game Dedicated Server
After=network.target
Wants=network-online.target
[Service]
Type=simple
User=steam
Group=steam
WorkingDirectory=/home/steam/gameserver
ExecStartPre=/home/steam/steamcmd/steamcmd.sh +force_install_dir /home/steam/gameserver +login anonymous +app_update APP_ID +quit
ExecStart=/home/steam/gameserver/start.sh
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure
RestartSec=30
StartLimitIntervalSec=300
StartLimitBurst=5
TimeoutStartSec=180
TimeoutStopSec=60
StandardOutput=journal
StandardError=journal
SyslogIdentifier=gameserver
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target
# Enable service (auto-start on boot)
sudo systemctl daemon-reload
sudo systemctl enable gameserver
# Service management
sudo systemctl start gameserver
sudo systemctl stop gameserver
sudo systemctl restart gameserver
sudo systemctl status gameserver
# View logs
sudo journalctl -u gameserver -f
sudo journalctl -u gameserver --since "1 hour ago"
| Option | Description |
|---|---|
| no | No restart |
| on-success | Only on successful exit |
| on-failure | On error (exit code != 0) |
| on-abnormal | On signal or timeout |
| on-watchdog | On watchdog timeout |
| always | Always restart |
[Service]
Restart=always
RestartSec=15
StartLimitIntervalSec=600
StartLimitBurst=10
This configuration:
sudo systemctl reset-failed gameserver
sudo systemctl start gameserver
nano ~/watchdog.sh
#!/bin/bash
SERVICE="gameserver"
LOG="/home/steam/watchdog.log"
while true; do
if ! systemctl is-active --quiet $SERVICE; then
echo "$(date): $SERVICE not running, restarting..." >> $LOG
sudo systemctl restart $SERVICE
sleep 30
fi
sleep 60
done
chmod +x ~/watchdog.sh
nano ~/watchdog_advanced.sh
#!/bin/bash
SERVICE="gameserver"
PORT=27015
LOG="/home/steam/watchdog.log"
MAX_RETRIES=3
RETRY_COUNT=0
check_port() {
ss -tuln | grep -q ":$PORT "
return $?
}
check_process() {
systemctl is-active --quiet $SERVICE
return $?
}
while true; do
if ! check_process; then
echo "$(date): Process not running, restarting..." >> $LOG
sudo systemctl restart $SERVICE
RETRY_COUNT=$((RETRY_COUNT + 1))
sleep 60
elif ! check_port; then
echo "$(date): Port $PORT not responding, checking..." >> $LOG
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
echo "$(date): $MAX_RETRIES attempts failed, restarting server..." >> $LOG
sudo systemctl restart $SERVICE
RETRY_COUNT=0
fi
sleep 30
else
RETRY_COUNT=0
fi
sleep 60
done
chmod +x ~/watchdog_advanced.sh
sudo nano /etc/systemd/system/gameserver-watchdog.service
[Unit]
Description=Game Server Watchdog
After=gameserver.service
Requires=gameserver.service
[Service]
Type=simple
User=steam
ExecStart=/home/steam/watchdog_advanced.sh
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable gameserver-watchdog
sudo systemctl start gameserver-watchdog
sudo apt install tmux -y
nano ~/start_tmux.sh
#!/bin/bash
SESSION="gameserver"
tmux kill-session -t $SESSION 2>/dev/null
tmux new-session -d -s $SESSION
tmux send-keys -t $SESSION "cd ~/gameserver && ./start.sh" C-m
echo "Server started in tmux session '$SESSION'."
echo "To attach: tmux attach -t $SESSION"
chmod +x ~/start_tmux.sh
tmux attach -t gameserver # Attach to session
# Ctrl+B, then D # Detach from session
tmux list-sessions # List sessions
tmux kill-session -t gameserver # Kill session
sudo apt install screen -y
nano ~/start_screen.sh
#!/bin/bash
SCREEN_NAME="gameserver"
screen -S $SCREEN_NAME -X quit 2>/dev/null
screen -dmS $SCREEN_NAME bash -c "cd ~/gameserver && ./start.sh"
echo "Server started in screen '$SCREEN_NAME'."
echo "To attach: screen -r $SCREEN_NAME"
chmod +x ~/start_screen.sh
screen -r gameserver # Attach to screen
# Ctrl+A, then D # Detach from screen
screen -ls # List screens
screen -S gameserver -X quit # Kill screen
nano ~/auto_update_restart.sh
#!/bin/bash
SERVICE="gameserver"
LOG="/home/steam/update.log"
echo "$(date): Starting update..." >> $LOG
sudo systemctl stop $SERVICE
sleep 10
~/steamcmd/steamcmd.sh +force_install_dir ~/gameserver +login anonymous +app_update APP_ID +quit >> $LOG 2>&1
sudo systemctl start $SERVICE
echo "$(date): Update complete." >> $LOG
chmod +x ~/auto_update_restart.sh
crontab -e
0 4 * * * /home/steam/auto_update_restart.sh
With systemd service configuration, watchdog scripts, and tmux/screen usage, you can ensure your game server runs 24/7 without interruption. Proper restart policies and automatic update mechanisms automate server management. REXE VDS reliable infrastructure ensures your server is always accessible.
خدمة systemd تضمن تشغيل خادمك تلقائياً عند بدء النظام وإعادة تشغيله عند التعطل.
كلاهما معدد طرفيات. tmux أكثر حداثة وغنى بالميزات، بينما screen أقدم وأكثر انتشاراً.
سكريبت watchdog يتحقق بانتظام من تشغيل الخادم. إذا توقف الخادم، يعيد تشغيله تلقائياً.
اضبط معلمات Restart و RestartSec و StartLimitIntervalSec و StartLimitBurst في ملف خدمة systemd.
استخدم journalctl -u gameserver -f لعرض السجلات المباشرة.
دليل شامل لتثبيت خادم FiveM على REXE VDS: إعداد txAdmin، إعدادات المنافذ وتحسين الأداء لخوادم GTA V Roleplay. ابدأ خادمك في دقائق.
دليل شامل لتثبيت خادم Paper/Spigot Minecraft على REXE VDS: إعدادات Java، إدارة الإضافات وتحسين الأداء للحصول على تجربة لعب مستقرة.
دليل شامل لتثبيت خادم CS2 المخصص على REXE VDS: SteamCMD، رمز GSLT، إعداد الخادم، أوضاع اللعب وحماية DDoS عبر Path Panel.