Mods / VS Server Restarter

Tags: #Utility
Author: rhetorical
Side: Server
Created: Sep 18th at 6:34 PM
Last modified: Sep 18th at 6:35 PM
Downloads: 46
Follow Unfollow 3

Latest release (for Vintage Story 1.21.0 and 1.21.1, potentially outdated):
vsserverrestarter-1.0.0.zip  1-click install


This is a simple mod that simply stops the server once each day at a configurable time. Useful when you have a script to automatically restart the server.

Once the time configured is reached, it will give announce to the server at 5 minutes, 1 minute, and 30 seconds out to the server that a restart is coming so players have an opportunity to act accordingly.


There is a config generated in which you may set the time for a restart in a "hh:mm" format. Example: "03:25" for 3:25 AM, "15:25" for 3:25 PM.

The default time is "03:25".

 

Example script I'm using (Windows):

 

autostarter.cmd

@echo off
Title Vintage Story Server
:start
VintageStoryServer.exe
timeout /t 10
cls
goto start

Mod Version Mod IdentifierFor Game version Downloads Released Changelog Download 1-click mod install*
1.0.0 vsserverrestarter 46 Sep 18th at 6:35 PM Empty vsserverrestarter-1.0.0.zip 1-click install

2 Comments (oldest first | newest first)

💬 Stefonio, Nov 25th at 5:57 PM

Why is this called server restarter if it doesn't actually restart the server? It's like if a mod that added chicken was called "More Chickens", but then it only adds eggs, with the description saying "Useful when you have a mod that adds more chickens"

💬 Electrified, Sep 20th at 5:09 AM

FYI on Ubuntu/Linux, this can also be achieved by setting up a cron job.  I have one set that checks for players online, and if there is player, it will ask them to logoff then check every 1 minute, and ask again, until everyone is logged off.  Once logged off it will auto save. then soft stop the server, wait a bit, then reboot the server box.  Then you also just have a startup service that auto starts the game on boot up.

 

here is the .sh code for what the cron job scheduler goes too.

 

Spoiler

#!/bin/bash

# Configuration
SCREEN_NAME="vintagestory"
VS_DIR="/home/xxxx/vintagestory"
TEMP_LOG="/tmp/vs-check-output.log"
LOG_FILE="$VS_DIR/reboot-log.txt"
RESTART_NOTICE="[SERVER AUTO-MESSAGE] [!] Server restart needed. Please finish what you're doing and log off. Next check in 1 minute."
WAIT_SECONDS=60 # Set to 20 for testing, 60 (1 min) for live


# Loop until no players are online
while true; do
echo "🔄 Checking for active players..."

# Clean previous log
rm -f "$TEMP_LOG"
screen -S "$SCREEN_NAME" -X logfile "$TEMP_LOG"
screen -S "$SCREEN_NAME" -X log on

# Send command to server
screen -S "$SCREEN_NAME" -X stuff "/list clients$(printf \\r)"
sleep 6 # Give server time to respond

# Stop log capture
screen -S "$SCREEN_NAME" -X log off

# Show what's in the log (for debug)
echo "--- Raw log output ---"
cat "$TEMP_LOG"
echo "----------------------"

# Check for real player connections
HAS_PLAYERS=$(grep -P "^\[\d+\] .+ \[::ffff:" "$TEMP_LOG")

if [ -z "$HAS_PLAYERS" ]; then
echo "✅ No players online. Proceeding with autosave, sync, and reboot..."
echo "$(date): No players online. Reboot sequence started." >> "$LOG_FILE"

# Save world
screen -S "$SCREEN_NAME" -X stuff "/autosavenow$(printf \\r)"
sleep 5

# Stop server
screen -S "$SCREEN_NAME" -X stuff "/stop$(printf \\r)"

echo "$(date): /stop issued. Waiting 15s before reboot..." >> "$LOG_FILE"
echo "⏳ Waiting 15 seconds for server to shut down gracefully..."
sleep 15

sudo /sbin/reboot
exit 0
else
echo "❌ Players online. Sending in-game warning and retrying in $((WAIT_SECONDS / 60)) minutes..."
screen -S "$SCREEN_NAME" -X stuff "$RESTART_NOTICE$(printf \\r)"
sleep "$WAIT_SECONDS"
fi
done

 (edit comment delete)
Основной веб-сайт | Почтовый сервер | FTP сервер | Административная панель | API интерфейс | Content Delivery Network | Статические файлы | Ресурсы сайта | Изображения | Файловое хранилище | Блог | Интернет-магазин | Техническая поддержка | Справочная система | Документация | Форум | Новости | Загрузки | Демонстрация | Тестовая среда | Приложение | Медиа контент | Разработка | Промежуточная среда | Бета версия | Безопасная зона | Вход в систему | Панель управления | Портал | Система управления контентом