Skip to content

Commit 2b71ace

Browse files
committed
Updated script to wait for database and lanuch server in order.
Renamed services so they're more obvious. Changed the /code directory to /topaz so it's more obvious what it contains. Updated documentation to reflect changes Cleaned up new lines at end of file. I have tested and am able to successfully launch the server create an account and character then log into the game
1 parent af4f33c commit 2b71ace

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

DOCKER.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This guide assumes you have Docker (https://www.docker.com/) installed on your m
55

66
## How to start the server
77

8+
* Launch docker
89
* Pull the repo
910
* Open powershell or whatever terminal you're using and navigate to the topaz directory
1011
* Type `docker-compose up -d` (the `-d` is optional and will free up -detach- the terminal)
@@ -14,18 +15,18 @@ Note the zone IPs are not updated in the DB and will default to 127.0.0.1 so you
1415

1516
## How to restart the Server/DB
1617

17-
The server runs in the "code" service and the database in the "db" service and will likely be named something like `topaz_code_1` similarly the database will be something like `topaz_db_1`. To see the names assigned to your services type `docker ps`. To restart them you can use the `docker restart` command such as `docker restart topaz_code_1`.
18+
The server runs in the "game" service and the database in the "db" service and will likely be named something like `topaz_game_1` similarly the database will be something like `topaz_db_1`. To see the names assigned to your services type `docker ps`. To restart them you can use the `docker restart` command such as `docker restart topaz_game_1`.
1819

19-
Alternatively you can stop and start individual services with `docker stop conainer_name` and `docker start container_name` where `container_name` is the container name from the `docker ps` command. The run order should be "database" then "code".
20+
Alternatively you can stop and start individual services with `docker stop conainer_name` and `docker start container_name` where `container_name` is the container name from the `docker ps` command. The run order should be "database" then "game".
2021

2122
## Connect to server terminal
2223

23-
If you need to access the terminal on the server you can enter `docker exe -it topaz_code_1 sh` where `topaz_code_1` is the container name from the `docker ps` command. To exit type `exit`.
24+
If you need to access the terminal on the server you can enter `docker exe -it topaz_game_1 sh` where `topaz_game_1` is the container name from the `docker ps` command. To exit type `exit`.
2425

2526
## Transfer files to server from local machine
2627

27-
If you need to transfer files from your local machine to the server you can use the `docker cp` command. All code on the server exists in the `/code` directory. See below for example.
28+
If you need to transfer files from your local machine to the server you can use the `docker cp` command. All code on the server exists in the `/topaz` directory. See below for example.
2829
This is useful for things like updating and testing the lua scripts without needing to restart the server.
2930

30-
Example copying godmode.lua script from local machine to server (where server name is `topaz_code_1`):
31-
`docker cp scripts/commands/godmode.lua topaz_code_1:/code/scripts/commands/godmode.lua`
31+
Example copying godmode.lua script from local machine to server (where server name is `topaz_game_1`):
32+
`docker cp scripts/commands/godmode.lua topaz_game_1:/topaz/scripts/commands/godmode.lua`

Dockerfile

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,19 @@ ENV TPZ_DB_USER=topazadmin
1010
ENV TPZ_DB_USER_PASSWD=topazisawesome
1111
ENV TPZ_DB_NAME=tpzdb
1212

13-
# Working directory will be /code meaning that the contents of topaz will exist in /code
14-
WORKDIR /code
13+
# Working directory will be /topaz meaning that the contents of topaz will exist in /topaz
14+
WORKDIR /topaz
1515

1616
# Update and install all requirements as well as some useful tools such as net-tools and nano
1717
RUN apt update && apt install -y net-tools nano build-essential software-properties-common g++-8 luajit-5.1-dev libzmq3-dev luarocks python3.7 cmake pkg-config g++ dnsutils git mariadb-server libluajit-5.1-dev libzmq3-dev autoconf pkg-config zlib1g-dev libssl-dev python3.6-dev libmysqlclient-dev
1818

19-
# Copy everything from the host machine topaz folder to /code
20-
ADD . /code
19+
# Copy everything from the host machine topaz folder to /topaz
20+
ADD . /topaz
2121

22-
RUN mkdir build && cd build && cmake .. && make -j $(nproc) && cd .. && rm -r /code/build
22+
RUN mkdir build && cd build && cmake .. && make -j $(nproc) && cd .. && rm -r /topaz/build
2323

2424
# Copy the docker config files to the conf folder instead of the default config
2525
COPY /conf/default/* conf/
2626

2727
# Startup the server when the container starts
28-
ENTRYPOINT ./tools/waitfordb.sh && \
29-
nohup ./topaz_connect > topaz_connect.log & \
30-
nohup ./topaz_game > topaz_game.log & \
31-
./topaz_search > topaz_search.log
28+
ENTRYPOINT ./tools/wait_for_db_then_launch.sh

docker-compose.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ services:
1717
- "3306:3306"
1818

1919
# Ease of access tool for the DB, you can type in localhost:8080 to get a web interface to the DB. You can log in with root:topazisawesome
20-
adminer:
20+
db-admin-portal:
2121
image: adminer
2222
restart: always
2323
depends_on:
@@ -26,7 +26,7 @@ services:
2626
- 8080:8080
2727

2828
# The server service
29-
code:
29+
game:
3030
# Build whatever is in the Dockerfile in the topaz root folder
3131
build: .
3232
depends_on:
@@ -39,4 +39,4 @@ services:
3939
# topaz_search
4040
- "54002:54002/tcp"
4141
# topaz_game
42-
- "54230:54230/udp"
42+
- "54230:54230/udp"

tools/wait_for_db_then_launch.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
while ! mysql --host=$TPZ_DB_HOST --port=$TPZ_DB_PORT --user=$TPZ_DB_USER --password=$TPZ_DB_USER_PASSWD -e "USE $TPZ_DB_NAME; SELECT 1 FROM zone_weather LIMIT 1"; do
4+
sleep 5
5+
done
6+
sleep 5
7+
echo "starting topaz_connect"
8+
nohup ./topaz_connect > topaz_connect.log &
9+
sleep 5
10+
echo "starting topaz_game"
11+
nohup ./topaz_game > topaz_game.log &
12+
sleep 5
13+
echo "starting topaz_search"
14+
./topaz_search > topaz_search.log

tools/waitfordb.sh

-5
This file was deleted.

0 commit comments

Comments
 (0)