Sign in

How TetraForce runs Godot on AWS

Gameplay image captured from community live stream by Fornclake
AWS Diagram displaying which services are used within TetraForce’s cloud infrastructure

Dockerization

FROM centos:centos8

RUN yum install -y wget unzip libXcursor openssl openssl-libs libXinerama libXrandr-devel libXi alsa-lib pulseaudio-libs mesa-libGL

ENV GODOT_VERSION "3.2.2"

# Install Godot Server
RUN wget -q https://downloads.tuxfamily.org/godotengine/${GODOT_VERSION}/Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip \
&& unzip Godot_v${GODOT_VERSION}-stable_linux_headless.64.zip \
&& mv Godot_v${GODOT_VERSION}-stable_linux_headless.64 /usr/local/bin/godot \
&& chmod +x /usr/local/bin/godot

# Create Runtime User
RUN useradd -d /tetra tetra


# Add pck file
ADD build/TetraForce.pck /tetra/TetraForce.pck

CMD /usr/local/bin/godot --main-pack /tetra/TetraForce.pck --empty-server-timeout=300

Server Management

The REST API

CloudWatch Events

{
"source": ["aws.ecs"],
"detail-type": [ "ECS Task State Change" ]
}

Client Integration

export(String) var api_endpoint = "api.tetraforce.io"

var _http_client : HTTPRequest
# Asynchronous coroutine.
# Requests API for data from a specific server
# Returns: {"message": [MESSAGE], "data" : [DATA] }
func get_server(lobby : String) -> Dictionary:
_http_client.request("https://" + api_endpoint + "/get_servers?server=" + str(lobby), [], true, HTTPClient.METHOD_GET)
var result = yield(_http_client, "request_completed")
if len(result) > 3 and result[1] == 200:
var json : JSONParseResult = JSON.parse(result[3].get_string_from_utf8())
if json.error:
return _build_error_message(json.error_string)
return json.result

return _build_error_message("Request failed!")

What’s next?

Related Links

AWS Community Builder & Cloud Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store