Загорелась идея поднять сервер SS14, но на очень дешёвом хосте, да и ещё и со своей сборкой. Недолго думая взял машину из под OpenTTD, где ещё хоститься и VPN с ботом, и начал мудрить.
Начнём с ингридиентов:
- Форк русского репозитория
- «Лучший бюджетный хостинг» — по словам хоста
- Куча времени
Первые проблемы
Всё началось с хоста доставки контента. Если вы пришли из Garry’s Mod, то SS14 даст вам по лицу со своим zip и постоянными ребилдами, если вы изменили одну строку.
Спасибо GitHub, что можно настроить action. Имеем скрипт, который сам всё билдит и заливает на сервер через SFTP:
name: Publish
concurrency:
group: publish
on:
workflow_dispatch:
schedule:
- cron: '0 1 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.100
- name: Get Engine Tag
run: |
cd RobustToolbox
git fetch --depth=1
- name: Package all
run: |
Tools/package_server_build.py -p win-x64 linux-x64 osx-x64 linux-arm64
Tools/package_client_build.py
- name: Update Build Info
run: Tools/gen_build_info.py
- name: Shuffle files around
run: |
mkdir "release/${{ github.sha }}"
mv release/*.zip "release/${{ github.sha }}"
- name: Upload files to mothership
uses: appleboy/scp-action@master
with:
host: ${{ secrets.BUILDS_HOST }}
port: ${{ secrets.BUILDS_PORT }}
username: ${{ secrets.BUILDS_USERNAME }}
password: ${{ secrets.BUILDS_SSH_KEY }}
source: "release/${{ github.sha }}"
target: ${{ secrets.BUILDS_PATH }}
use_insecure_cipher: true
strip_components: 1
secrets.N — добавляются в Enviroment (настройки репозитория).
Учтите, что клиент в любом случае будет перекачивать весь клиентский билд заново, даже если вы изменили только 1 строку/спрайт и т.п.
Предупреждение: если вы захотели добавить спрайт, то лучше использовать уникальное имя, иначе игра подтянет уже существующий у игрока контент.
Хостинг сервера
Взял самый дешёвый тариф за 150р/месяц
2 ядра (AMD Epyc?) | 4GB RAM | 30GB ROM | 100Mbit/sec канал |
С холодного старта сервер ест ~10% CPU
После захода 1-3 игроков ~35% CPU
Зачем такая слабая машина? «Тестируем сервер на пределе возможностей». Если сервер выдержит примерно ~20-30 онлайна, то значит SS14 можно будет хостить на этой дешманской печке, ну или взять тариф подороже.
Сам конфиг сервера:
# Welcome to the example configuration file!
# Remember that if this is in bin/Content.Server or such, it may be overwritten on build.
# Consider copying it and using the --config-file and --data-dir options.
[log]
path = "logs"
format = "log_%(date)s-%(time)s.txt"
level = 1
enabled = false
[net]
tickrate = 30
port = 1212
bindto = "::,0.0.0.0"
# Automatic port forwarding!
# Disabled by default because you may not want to do this.
# upnp = true
[status]
# The status server is the TCP side, used by the launcher to determine engine version, etc.
# To be clear: Disabling it makes the launcher unable to connect!
enabled = true
# This is the address and port the status server binds to.
# The port is by default set based on net.port so it will follow what you set there.
# bind = "*:1212"
# This is the address of the SS14 server as the launcher uses it.
# This is only needed if you're proxying the status HTTP server -
# by default the launcher will assume the address and port match that of the status server.
# connectaddress = "udp://localhost:1212"
[game]
hostname = "[RU][MRP] Космический Засранец - Public Test"
desc = "Тестируем сервер на пределе возможностей"
# map = "Saltern"
maxplayers = 60
soft_max_players = 60
welcomemsg = ""
lobbyenabled = true
[infolinks]
discord = "https://srv0.troit5ky.ru/discord"
github = "https://github.com/troit5ky/space-station-14"
wiki = "https://station14.ru/"
website = "https://pika-soft.ru"
[vote]
preset_enabled = false
map_enabled = true
[console]
# If this is true, people connecting from this machine (loopback)
# will automatically be elevated to full admin privileges.
# This literally works by checking if address == 127.0.0.1 || address == ::1
loginlocal = true
[hub]
# Set to true to show this server on the public server list
# Before enabling this, read: https://docs.spacestation14.io/hosts/hub-rules
advertise = true
# Comma-separated list of tags, useful for categorizing your server.
# See https://docs.spacestation14.io/hosts/hub-rules for more details on this when it becomes relevant.
tags = ""
# URL of your server. Fill this in if you have a domain name,
# want to use HTTPS (with a reverse proxy), or other advanced scenarios.
# Must be in the form of an ss14:// or ss14s:// URI pointing to the status API.
server_url = ""
[build]
# *Absolutely all of these can be supplied using a "build.json" file*
# For further information, see https://github.com/space-wizards/space-station-14/blob/master/Tools/gen_build_info.py
# The main reason you'd want to supply any of these manually is for a custom fork and if you have no tools.
# Useful to override if the existing version is bad.
# See https://github.com/space-wizards/RobustToolbox/tags for version values, remove the 'v'.
# The value listed here is almost certainly wrong - it is ONLY a demonstration of format.
# engine_version = "0.7.6"
# This one is optional, the launcher will delete other ZIPs of the same fork to save space.
fork_id = "asshole"
# Automatically set if self-hosting client zip, but otherwise use this when updating client build.
# There is no required format, any change counts as a new version.
version = "a6f51b48dbb207a2b3c5cb90386a77416757e385"
# This is where the launcher will download the client ZIP from.
# If this isn't supplied, the server will check for a file called "Content.Client.zip",
# and will host it on the status server.
# If that isn't available, the server will attempt to find and use "../../Resources" and
# "../../bin/Content.Client" to automatically construct a client zip.
# It will then host this on the status server.
# Note that these paths do not work on "FULL_RELEASE" servers.
# FULL_RELEASE servers expect to be used with a specific "packaged" layout.
# As such, whatever script you're using to package them is expected to create the ZIP.
download_url = "https://srv0.troit5ky.ru/cdn/a6f51b48dbb207a2b3c5cb90386a77416757e385/SS14.Client.zip"
# Build hash - this is a *capitalized* SHA256 hash of the client ZIP.
# Optional in any case and automatically set if hosting a client ZIP.
# This hash is an example only.
#build = "07f0839f41d7c33d8fa52b34f5083f5b0f1ec49b"
[auth]
# Authentication (accounts):
# 0 = Optional, 1 = Required, 2 = Disabled
# Presumably do require authentication on any public server.
mode = 1
# If true, even if authentication is required, localhost is still allowed to login directly regardless.
# allowlocal = true
# You should probably never EVER need to touch this, but if you need a custom auth server,
# (the auth server being the one which manages Space Station 14 accounts), you change it here.
# server = https://central.spacestation14.io/auth/
Ко всем основным параметрам уже есть пояснения и примеры.
Предупреждение: если захотите отыскать другие переменные, то придётся лезть в код самого CCVar, который написан на C#.
P.S.
Если из этого выйдет что-то интересно, то буду дополнять/писать статьи с новыми проблемами и их решениями.
Азерта упала и лежит 5 дней, в пизду)