Feat(Docker/bash): docker-compose system rework (#4488)

## ⚠️ATTENTION! ⚠️ Upgrading procedure:

**Database:** After this PR will be merged you need to backup your DB first (you can use the db-assembler or any mysql client to generate the dump) and restore it after.  The reason is that we use now docker named volumes instead of binded ones to improve performance.

**Conf & client data**: if you use the default configuration, both the etc and the data folder are now available inside the **/env/docker**. 

Finally, you can cleanup the /docker folder previously used by our system.

## Changes Proposed:

This PR will implement the [devcontainer ](https://code.visualstudio.com/docs/remote/containers) feature for VSCode. Allowing us to develop and debug directly within the container in the same way on all OSes.

* Implemented support for vscode dev-container feature by remote-extension suite
* Docker performance optimizations for MacOS and non-linux hosts
* Bash system improvements
* Implemented first command using Deno runtime environment (typescript) and [commander.js]
* Implemented wait mechanism for db_assembler
* Implemented db migration command
* possibility to run the authserver and worldserver with GDB using the integrated simple-restarter
* Implemented docker multi-stage mechanism to use one single Dockerfile for all the services
* client-data downloader now creates a placeholder to avoid downloading the same version of data files multiple times
* deployment of pre-compiled docker images on [docker hub](https://hub.docker.com/u/acore), you can test them [here](https://github.com/azerothcore/acore-docker)
This commit is contained in:
Yehonal
2021-04-22 09:57:05 +02:00
committed by GitHub
parent 4a8faafaff
commit 380f406248
100 changed files with 2747 additions and 777 deletions

View File

@@ -1,12 +1,15 @@
function registerHooks() { hwc_event_register_hooks "$@"; }
function runHooks() { hwc_event_run_hooks "$@"; }
function registerHooks() { acore_event_registerHooks "$@"; }
function runHooks() { acore_event_runHooks "$@"; }
source "$AC_PATH_CONF/dist/config.sh" # include dist to avoid missing conf variables
if [ -f "$AC_PATH_CONF/config.sh" ]; then
source "$AC_PATH_CONF/config.sh" # should overwrite previous
# first check if it's defined in env, otherwise use the default
USER_CONF_PATH=${USER_CONF_PATH:-"$AC_PATH_CONF/config.sh"}
if [ -f "$USER_CONF_PATH" ]; then
source "$USER_CONF_PATH" # should overwrite previous
else
echo "NOTICE: file <$AC_PATH_CONF/config.sh> has not been found, you should create and configure it."
echo "NOTICE: file <$USER_CONF_PATH> has not been found, you should create and configure it."
fi
#
@@ -15,7 +18,7 @@ fi
for entry in "$AC_PATH_MODULES/"*/include.sh
do
if [ -e "$entry" ]; then
if [ -e "$entry" ]; then
source "$entry"
fi
done

22
apps/bash_shared/deno.sh Normal file
View File

@@ -0,0 +1,22 @@
DENO_MIN_VERSION="1.7.4"
function denoInstall() {
{ # try
echo "Deno version check:" && denoCmd upgrade --version $DENO_MIN_VERSION
} ||
{ # catch
echo "Installing Deno..."
# just one line of command that works on all OSes
# (temporary cd into AC_PATH_DEPS)
curl -fsSL https://deno.land/x/install/install.sh | DENO_INSTALL="$AC_PATH_DEPS/deno" sh
}
}
function denoCmd() {
(cd "$AC_PATH_ROOT" ; ./deps/deno/bin/deno "$@")
}
function denoRunFile() {
denoCmd run --allow-all --unstable "$@"
}

View File

@@ -1,7 +1,7 @@
[[ ${GUARDYVAR:-} -eq 1 ]] && return || readonly GUARDYVAR=1 # include it once
# force default language for applications
LC_ALL=C
LC_ALL=C
AC_PATH_APPS="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"
@@ -9,9 +9,13 @@ AC_PATH_SHARED="$AC_PATH_APPS/bash_shared"
source "$AC_PATH_SHARED/defines.sh"
source "$AC_PATH_DEPS/hw-core/bash-lib-event/src/hooks.sh"
source "$AC_PATH_DEPS/acore/bash-lib/src/event/hooks.sh"
source "$AC_PATH_SHARED/common.sh"
source "$AC_PATH_SHARED/deno.sh"
denoInstall
[[ "$OSTYPE" = "msys" ]] && AC_BINPATH_FULL="$BINPATH" || AC_BINPATH_FULL="$BINPATH/bin"

View File

@@ -2,6 +2,21 @@
PROMPT_USER=""
PROMPT_PASS=""
function dbasm_waitMysqlConn() {
DBHOST="$1"
DBPORT="$2"
COUNT=0
while ! mysqladmin ping -h"$DBHOST" --port="$DBPORT" --silent; do
((COUNT++))
if [ $COUNT -gt $DBASM_WAIT_RETRIES ]; then
echo "DBASM Timeout: Cannot ping mysql!" 1>&2
exit 64
fi
echo "Cannot ping mysql, retry in $DBASM_WAIT_TIMEOUT seconds (remaining: $COUNT/$DBASM_WAIT_RETRIES)..."
sleep $DBASM_WAIT_TIMEOUT
done
}
# use in a subshell
function dbasm_resetExitCode() {
exit 0
@@ -11,7 +26,7 @@ function dbasm_mysqlExec() {
confs=$1
command=$2
options=$3
# MYSQL_PORT needs to be reseted as the next eval might not overwite the current value causing the commands to use wrong port
MYSQL_PORT=3306
eval $confs
@@ -21,6 +36,7 @@ function dbasm_mysqlExec() {
MYSQL_PASS=$PROMPT_PASS
fi
dbasm_waitMysqlConn $MYSQL_HOST $MYSQL_PORT
export MYSQL_PWD=$MYSQL_PASS
@@ -57,7 +73,7 @@ function dbasm_mysqlExec() {
eval $_confs
echo "Grant permissions for ${MYSQL_USER}'@'${MYSQL_HOST} to ${_dbname}"
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -P "$MYSQL_PORT" -e "GRANT ALL PRIVILEGES ON ${_dbname}.* TO '${MYSQL_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
"$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -P "$MYSQL_PORT" -e "GRANT ALL PRIVILEGES ON ${_dbname}.* TO '${MYSQL_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION; FLUSH PRIVILEGES;"
done
else
exit
@@ -109,9 +125,13 @@ function dbasm_createDB() {
echo "$dbname database exists"
else
echo "Creating DB ${dbname} ..."
dbasm_mysqlExec "$confs" "CREATE DATABASE \`${dbname}\`" ""
dbasm_mysqlExec "$confs" "CREATE DATABASE \`${dbname}\`;" ""
echo "Creating User ${CONF_USER}@${MYSQL_HOST} identified by ${CONF_PASS}..."
dbasm_mysqlExec "$confs" "CREATE USER IF NOT EXISTS '${CONF_USER}'@'${MYSQL_HOST}' IDENTIFIED BY '${CONF_PASS}';"
dbasm_mysqlExec "$confs" "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO '${CONF_USER}'@'${MYSQL_HOST}' WITH GRANT OPTION;"
echo "Granting user privileges on: ${dbname} ..."
dbasm_mysqlExec "$confs" "GRANT ALL PRIVILEGES ON \`${dbname}\`.* TO '${CONF_USER}'@'${MYSQL_HOST}'"
echo "Flush privileges"
dbasm_mysqlExec "$confs" "FLUSH PRIVILEGES;"
fi
}
@@ -247,7 +267,7 @@ function dbasm_db_backup() {
name="DB_"$uc"_NAME"
dbname=${!name}
# MYSQL_PORT needs to be reseted as the next eval might not overwite the current value causing the commands to use wrong port
MYSQL_PORT=3306
eval $confs;
@@ -299,7 +319,7 @@ function dbasm_db_import() {
fi
echo "importing $1 - $2 ..."
# MYSQL_PORT needs to be reseted as the next eval might not overwite the current value causing the commands to use wrong port
MYSQL_PORT=3306
eval $confs;
@@ -309,6 +329,8 @@ function dbasm_db_import() {
MYSQL_PASS=$PROMPT_PASS
fi
dbasm_waitMysqlConn $MYSQL_HOST $MYSQL_PORT
export MYSQL_PWD=$MYSQL_PASS

View File

@@ -2,7 +2,7 @@
ROOTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../" && pwd )"
source $ROOTPATH"/apps/bash_shared/includes.sh"
source "$ROOTPATH/apps/bash_shared/includes.sh"
if [ -f "./config.sh" ]; then
source "./config.sh" # should overwrite previous
@@ -24,7 +24,7 @@ function export() {
var_base_path="DB_"$database"_PATHS"
base_path=${!var_base_path%/}
base_conf="TPATH="$base_path";\
CLEANFOLDER=1; \
CHMODE=0; \
@@ -33,15 +33,15 @@ function export() {
FULL=0; \
DUMPOPTS='--skip-comments --skip-set-charset --routines --extended-insert --order-by-primary --single-transaction --quick'; \
"
var_base_conf="DB_"$database"_CONF"
base_conf=$base_conf${!var_base_conf}
var_base_name="DB_"$database"_NAME"
base_name=${!var_base_name}
bash $AC_PATH_DEPS"/drassil/mysql-tools/mysql-tools" dump "" $base_name "" "$base_conf"
bash "$AC_PATH_DEPS/acore/mysql-tools/mysql-tools" "dump" "" "$base_name" "" "$base_conf"
}
for db in ${DATABASES[@]}

128
apps/docker/Dockerfile Normal file
View File

@@ -0,0 +1,128 @@
#================================================================
#
# DEV: Stage used for the development environment
# and the locally built services
#
#=================================================================
FROM ubuntu:20.04 as dev
ARG USER_ID=1000
ARG GROUP_ID=1000
LABEL description="AC Worldserver Debug Container for use with Visual Studio"
# List of timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
ENV DOCKER=1
# set timezone environment variable
ENV TZ=Etc/UTC
# set noninteractive mode so tzdata doesn't ask to set timezone on install
ENV DEBIAN_FRONTEND=noninteractive
# install essentials
RUN apt-get update && apt-get install -y gdb gdbserver git dos2unix lsb-core sudo curl unzip
# copy everything so we can work directly within the container
# using tools such as vscode dev-container
COPY . /azerothcore
# install the required dependencies to run the worldserver
RUN /azerothcore/acore.sh install-deps
# change timezone in container
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
# Create a non-root user
RUN addgroup --gid $GROUP_ID acore && \
adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID acore && \
passwd -d acore && \
echo 'acore ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
RUN mkdir -p /azerothcore
# Correct permissions for non-root operations
RUN chown -R acore:acore \
/run \
/home/acore \
/opt/ \
/azerothcore
USER acore
WORKDIR /azerothcore
#================================================================
#
# BUILD STAGE: to prepare binaries for the production services
#
#=================================================================
FROM dev as build
RUN bash acore.sh compiler build
#================================================================
#
# SERVICE BASE: prepare the OS for the production-ready services
#
#=================================================================
FROM ubuntu:20.04 as servicebase
# List of timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# set timezone environment variable
ENV TZ=Etc/UTC
# set noninteractive mode so tzdata doesn't ask to set timezone on install
ENV DEBIAN_FRONTEND=noninteractive
COPY --from=build /azerothcore/env /azerothcore/env
# copy the sources from the host machine
COPY apps /azerothcore/apps
COPY bin /azerothcore/bin
COPY conf /azerothcore/conf
COPY data /azerothcore/data
COPY deps /azerothcore/deps
COPY acore.json /azerothcore/acore.json
COPY acore.sh /azerothcore/acore.sh
# install the required dependencies to run the authserver
RUN apt-get update && apt-get install -y gdb gdbserver net-tools tzdata libmysqlclient-dev libace-dev mysql-client curl unzip;
# change timezone in container
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata
WORKDIR /azerothcore/
RUN cp -n "/azerothcore/env/docker/etc/worldserver.conf.dockerdist" "/azerothcore/env/dist/etc/worldserver.conf"
RUN cp -n "/azerothcore/env/docker/etc/authserver.conf.dockerdist" "/azerothcore/env/dist/etc/authserver.conf"
#================================================================
#
# AUTH SERVICE: create a ready-to-use authserver image
#
#=================================================================
FROM servicebase as authserver
CMD ./acore.sh run-authserver
#================================================================
#
# WORLD SERVICE: create a ready-to-use worldserver image
#
#=================================================================
FROM servicebase as worldserver
ENV DATAPATH=/azerothcore/env/dist/data
RUN /azerothcore/acore.sh client-data
CMD ./acore.sh run-worldserver

27
apps/docker/README.md Normal file
View File

@@ -0,0 +1,27 @@
# Run AzerothCore with Docker
*This readme it's a summary of the AzerothCore docker features.*
Docker. is a software that performs operating-system-level virtualization, allowing to wrap and launch applications inside containers.
Thanks to Docker, you can quickly setup and run AzerothCore in any operating system.
The **only** requirement is having [Docker](https://docs.docker.com/install/) installed into your system. Forget about installing mysql, visual studio, cmake, etc...
### Installation instructions
Check the [Install with Docker](https://www.azerothcore.org/wiki/Install-with-Docker) guide.
### Memory usage
The total amount of RAM when running all AzerothCore docker containers is **less than 2 GB**.
![AzerothCore containers memory](https://user-images.githubusercontent.com/75517/51078287-10e65b80-16b3-11e9-807f-f59a5844dae5.png)
### Docker containers vs Virtual machines
Using Docker will have the same benefits as using virtual machines, but with much less overhead:
![Docker containers vs Virtual machines](https://user-images.githubusercontent.com/75517/51078179-d4fec680-16b1-11e9-8ce6-87b5053f55dd.png)

View File

@@ -0,0 +1,6 @@
CUR_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# allow the user to override configs
if [ -f "$AC_PATH_CONF/config.sh" ]; then
source "$AC_PATH_CONF/config.sh" # should overwrite previous
fi

174
apps/docker/docker-cmd.ts Normal file
View File

@@ -0,0 +1,174 @@
import { Command } from "https://cdn.depjs.com/cmd/mod.ts";
import * as ink from "https://deno.land/x/ink/mod.ts";
import {
Input,
Select,
} from "https://deno.land/x/cliffy@v0.18.2/prompt/mod.ts";
const program = new Command();
program.name("acore.sh docker")
.description("Shell scripts for docker")
.version("1.0.0");
shellCommandFactory(
"start:app",
"Startup the authserver and worldserver apps",
"docker-compose --profile app up",
);
shellCommandFactory(
"start:app:d",
"Startup the authserver and worldserver apps in detached mode",
"docker-compose --profile app up -d",
);
shellCommandFactory(
"start:dev",
"Startup the dev server",
"docker-compose --profile dev up",
);
shellCommandFactory(
"build",
"Build the authserver and worldserver",
`docker-compose run --rm ac-dev-server bash bin/acore-docker-build`,
);
shellCommandFactory(
"build:clean",
"Clean build data",
`docker-compose run --rm ac-dev-server bash rm -rf var/build`,
);
shellCommandFactory(
"client-data",
"Download client data inside the ac-data volume",
"docker-compose run --rm ac-dev-server bash acore.sh client-data",
);
shellCommandFactory(
"db-import",
"Create and upgrade the database with latest updates",
"docker-compose run --rm ac-dev-server bash acore.sh db-assembler import-all",
);
shellCommandFactory(
"dashboard [args...]",
"Execute acore dashboard within a running ac-dev-server",
"docker-compose exec ac-dev-server bash acore.sh",
);
program.command("attach [service]")
.description("attach to a service")
.action(async (service: string | undefined) => {
const { run } = Deno;
let command = `docker-compose ps`;
if (service) {
command = `${command} ${service}`;
}
console.log(ink.colorize(`<green>>>>>> Running: ${command}</green>`));
let cmd = command.split(" ");
const res = Deno.run({
cmd,
cwd: process.cwd(),
stdout: "piped",
stderr: "piped",
});
const output = await res.output(); // "piped" must be set
let services = new TextDecoder().decode(output).split("\n");
services.pop();
services = services.slice(2);
res.close(); // Don't forget to close it
let selService: string;
if (services.length > 1) {
selService = await Select.prompt({
message: `Select a service`,
options: services,
});
} else {
selService = services[0];
}
command = `docker attach ${selService.split(" ")[0]}`;
console.log(ink.colorize(`<green>>>>>> Running: ${command}</green>`));
console.log(
ink.colorize(
"<yellow>NOTE: you can detach from a container and leave it running using the CTRL-p CTRL-q key sequence.</yellow>",
),
);
cmd = command.split(" ");
const shellCmd = run({
cmd,
cwd: process.cwd(),
});
await shellCmd.status();
shellCmd.close();
});
program.command("quit").description("Close docker command").action(()=> {
process.exit(0)
})
// Handle it however you like
// e.g. display usage
while (true) {
if (Deno.args.length === 0) {
program.outputHelp();
const command = await Input.prompt({
message: "Enter the command:",
});
await program.parseAsync(command.split(" "));
} else {
await program.parseAsync(Deno.args);
process.exit(0)
}
}
function shellCommandFactory(
name: string,
description: string,
command: string,
): Command {
return program.command(name)
.description(
`${description}. Command: \n"${ink.colorize(`<green>${command}</green>`)}"\n`,
)
.action(async (args: any[] | undefined) => {
const { run } = Deno;
console.log(ink.colorize(`<green>>>>>> Running: ${command}</green>`));
const cmd = command.split(" ");
if (Array.isArray(args)) {
cmd.push(...args);
}
const shellCmd = run({
cmd,
cwd: process.cwd(),
});
await shellCmd.status();
shellCmd.close();
});
}

View File

@@ -2,7 +2,7 @@ function inst_configureOS() {
echo "Platform: $OSTYPE"
case "$OSTYPE" in
solaris*) echo "Solaris is not supported yet" ;;
darwin*) source "$AC_PATH_INSTALLER/includes/os_configs/osx.sh" ;;
darwin*) source "$AC_PATH_INSTALLER/includes/os_configs/osx.sh" ;;
linux*)
# If $OSDISTRO is set, use this value (from config.sh)
if [ ! -z "$OSDISTRO" ]; then
@@ -68,7 +68,6 @@ function inst_cleanCompile() {
function inst_allInOne() {
inst_configureOS
inst_updateRepo
inst_compile
dbasm_import true true true
}
@@ -153,7 +152,7 @@ function inst_module_install {
if [[ "$b" != "none" ]]; then
Joiner:add_repo "https://github.com/azerothcore/$res" "$res" "$b" && echo "Done, please re-run compiling and db assembly. Read instruction on module repository for more information"
else
echo "Cannot install $res module: it doesn't exists or no version compatible with AC v$ACORE_VERSION are available"
echo "Cannot install $res module: it doesn't exists or no version compatible with AC v$ACORE_VERSION are available"
fi
echo "";
@@ -219,9 +218,31 @@ function inst_simple_restarter {
}
function inst_download_client_data {
local path="$AC_BINPATH_FULL"
# change the following version when needed
local VERSION=v10
echo "#######################"
echo "Client data downloader"
echo "#######################"
# first check if it's defined in env, otherwise use the default
local path="${DATAPATH:-$AC_BINPATH_FULL}"
dataVersionFile="$path/data-version"
[ -f "$dataVersionFile" ] && source "$dataVersionFile"
# create the path if doesn't exists
mkdir -p "$path"
if [ "$VERSION" == "$INSTALLED_VERSION" ]; then
echo "Data $VERSION already installed. If you want to force the download remove the following file: $dataVersionFile"
return
fi
echo "Downloading client data in: $path/data.zip ..."
curl -L https://github.com/wowgaming/client-data/releases/download/v10/data.zip > "$path/data.zip" \
&& unzip -o "$path/data.zip" -d "$path/" && rm "$path/data.zip"
curl -L https://github.com/wowgaming/client-data/releases/download/$VERSION/data.zip > "$path/data.zip" \
&& echo "unzip downloaded file..." && unzip -q -o "$path/data.zip" -d "$path/" \
&& echo "Remove downloaded file" && rm "$path/data.zip" \
&& echo "INSTALLED_VERSION=$VERSION" > "$dataVersionFile"
}

View File

@@ -6,24 +6,9 @@ source "$CURRENT_PATH/../../bash_shared/includes.sh"
AC_PATH_INSTALLER="$AC_PATH_APPS/installer"
J_VER_REQ="v0.8.3"
J_PATH="$AC_PATH_APPS/joiner"
J_PATH="$AC_PATH_DEPS/acore/joiner"
J_PATH_MODULES="$AC_PATH_MODULES"
#install/update and include joiner
if [ ! -d "$J_PATH/.git" ]; then
git clone https://github.com/azerothcore/joiner "$J_PATH" -b master
git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" reset --hard "$J_VER_REQ"
else
# legacy code, with new rev of joiner the update process is internally handled
_cur_branch=$(git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" rev-parse --abbrev-ref HEAD)
_cur_ver=$(git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" name-rev --tags --name-only $_cur_branch)
if [ "$_cur_ver" != "$J_VER_REQ" ]; then
git --git-dir="$J_PATH/.git" --work-tree="$J_PATH/" rev-parse && git --git-dir="$J_PATH/.git" --work-tree="$J_PATH/" fetch --tags origin master --quiet
git --git-dir="$J_PATH/.git/" --work-tree="$J_PATH/" reset --hard "$J_VER_REQ"
fi
fi
source "$J_PATH/joiner.sh"
if [ -f "$AC_PATH_INSTALLER/config.sh" ]; then

View File

@@ -7,13 +7,16 @@ UBUNTU_VERSION=$(lsb_release -sr);
sudo apt-get update -y
if [[ $CONTINUOUS_INTEGRATION ]]; then
sudo apt-get -y install build-essential libtool make cmake cmake-data clang openssl libgoogle-perftools-dev \
libssl-dev libmysqlclient-dev libmysql++-dev libreadline6-dev zlib1g-dev libbz2-dev libace-dev mysql-client \
libncurses5-dev ccache
# shared deps
sudo apt-get -y install make cmake clang curl unzip libmysqlclient-dev libace-dev
if [[ $CONTINUOUS_INTEGRATION || $DOCKER ]]; then
sudo apt-get -y install build-essential libtool cmake-data openssl libgoogle-perftools-dev \
libssl-dev libmysql++-dev libreadline6-dev zlib1g-dev libbz2-dev mysql-client \
libncurses5-dev ccache curl unzip
else
sudo apt-get install -y git cmake make gcc g++ clang libmysqlclient-dev \
sudo apt-get install -y git gcc g++ \
libssl-dev libbz2-dev libreadline-dev libncurses-dev \
mysql-server libace-6.* libace-dev curl unzip
mysql-server libace-6.*
fi

View File

@@ -19,7 +19,8 @@ options=(
"client-data: (gd): download client data from github repository (beta)" # 11
"run-worldserver (rw): execute a simple restarter for worldserver" # 12
"run-authserver (ra): execute a simple restarter for authserver" # 13
"quit: Exit from this menu" # 14
"docker (dr): Run docker tools" # 14
"quit: Exit from this menu" # 15
)
function _switch() {
@@ -66,7 +67,11 @@ function _switch() {
""|"ra"|"run-authserver"|"13")
inst_simple_restarter authserver
;;
""|"quit"|"14")
""|"dr"|"docker"|"14")
DOCKER=1 denoRunFile "$AC_PATH_APPS/docker/docker-cmd.ts" "${@:2}"
exit
;;
""|"quit"|"15")
echo "Goodbye!"
exit
;;

View File

@@ -2,7 +2,7 @@
export GDB_ENABLED=0
# [optional] gdb file
# default: gdb.txt
# default: gdb.conf
export GDB=""
# directory where binary are stored

View File

@@ -2,12 +2,12 @@
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
source "$PATH_RUNENGINE/run-engine"
# you must create your conf
# copying conf.sh.dist
# copying conf.sh.dist
# and renaming as below
source ./conf-auth.sh
source "./conf-auth.sh"
restarter

View File

@@ -2,12 +2,12 @@
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
source "$PATH_RUNENGINE/run-engine"
# you must create your conf
# copying conf.sh.dist
# copying conf.sh.dist
# and renaming as below
source ./conf-world.sh
source "./conf-world.sh"
restarter

View File

@@ -2,13 +2,12 @@
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
source "$PATH_RUNENGINE/run-engine"
# you must create your conf
# copying conf.sh.dist
# and renaming as below
source ./conf-auth.sh
source "./conf-auth.sh"
starter

View File

@@ -2,12 +2,12 @@
PATH_RUNENGINE="./"
source $PATH_RUNENGINE/run-engine
source "$PATH_RUNENGINE/run-engine"
# you must create your conf
# copying conf.sh.dist
# copying conf.sh.dist
# and renaming as below
source ./conf-world.sh
source "./conf-world.sh"
starter

View File

@@ -0,0 +1,4 @@
set logging on
set debug timestamp
run
bt

View File

@@ -2,56 +2,69 @@
#PARAMETER 1: directory
#PARAMETER 2: binary file
#PARAMETER 3: gdb on/off
_bin_path=$1
_bin_file=$2
bin_path="${1:-$AC_RESTARTER_BINPATH}"
bin_file="${2:-$AC_RESTARTER_BINFILE}"
with_gdb="${3:-$AC_RESTARTER_WITHGDB}"
CURRENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd )
_instant_crash_count=0
_restart_count=0
if [ "$#" -ne 2 ]; then
echo "Usage: $0 path filename"
echo "Example: $0 $HOME/azeroth-server/bin worldserver"
echo "Example: $0 $HOME/azerothcore/bin worldserver"
exit 1
fi
while true
do
if [ ! -f "$_bin_path/$_bin_file" ]; then
echo "$_bin_path/$_bin_file doesn't exists!"
if [ ! -f "$bin_path/$bin_file" ]; then
echo "$bin_path/$bin_file doesn't exists!"
exit 1
fi
STARTING_TIME=$(date +%s)
cd "$_bin_path" && "./$_bin_file" # &>/dev/null;
cd "$bin_path";
if [ "$with_gdb" = true ]; then
echo "Running with GDB enabled"
gdb -x "$CURRENT_PATH/gdb.conf" --batch "./$bin_file"
else
echo "Running without GDB"
"./$bin_file"
fi
_exit_code=$?
echo "exit code: $_exit_code"
# stop restarter on SIGKILL (disabled for now)
# 128 + 9 (SIGKILL)
#if [ $_exit_code -eq 137 ]; then
# echo "$_bin_file has been killed"
# echo "$bin_file has been killed"
# exit 0
#fi
echo "$_bin_file terminated, restarting..."
echo "$bin_file terminated, restarting..."
ENDING_TIME=$(date +%s)
DIFFERENCE=$(( $ENDING_TIME - $STARTING_TIME ))
((_restart_count++))
echo "$_bin_file Terminated after $DIFFERENCE seconds, termination count: : $_restart_count"
echo "$bin_file Terminated after $DIFFERENCE seconds, termination count: : $_restart_count"
if [ $DIFFERENCE -lt 10 ]; then
# increment instant crash if runtime is lower than 10 seconds
# increment instant crash if runtime is lower than 10 seconds
((_instant_crash_count++))
else
_instant_crash_count=0 # reset count
fi
if [ $_instant_crash_count -gt 5 ]; then
echo "$_bin_file Restarter exited. Infinite crash loop prevented. Please check your system"
echo "$bin_file Restarter exited. Infinite crash loop prevented. Please check your system"
exit 1
fi
done