feat(Tools/DbImport): implement separated app for importing DB (#11614)
This commit is contained in:
parent
c0ab2ab08e
commit
94528cd44d
48
.github/workflows/build_dbimport.yml
vendored
Normal file
48
.github/workflows/build_dbimport.yml
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
name: build-db
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master' # only default branch
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.head_ref }} || concat(${{ github.ref }}, ${{ github.workflow }})
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
# the result of the matrix will be the combination of all attributes, so we get os*compiler*modules builds
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
compiler: [clang12]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
name: ${{ matrix.compiler }}
|
||||||
|
env:
|
||||||
|
COMPILER: ${{ matrix.compiler }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-db
|
||||||
|
with:
|
||||||
|
path: var/ccache
|
||||||
|
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.ref }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.ref }}-
|
||||||
|
${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.compiler }}-
|
||||||
|
${{ env.cache-name }}-${{ matrix.os }}-
|
||||||
|
- name: Configure OS
|
||||||
|
run: source ./acore.sh install-deps
|
||||||
|
env:
|
||||||
|
CONTINUOUS_INTEGRATION: true
|
||||||
|
- name: Create conf/config.sh
|
||||||
|
run: source ./apps/ci/ci-conf-db.sh
|
||||||
|
- name: Build
|
||||||
|
run: source ./apps/ci/ci-compile.sh
|
||||||
|
- name: Process pending sql
|
||||||
|
run: bash bin/acore-db-pendings
|
||||||
|
- name: Dry run
|
||||||
|
run: source ./apps/ci/ci-dry-run.sh dbimport
|
||||||
2
.github/workflows/core_matrix_build.yml
vendored
2
.github/workflows/core_matrix_build.yml
vendored
@ -50,6 +50,8 @@ jobs:
|
|||||||
CONTINUOUS_INTEGRATION: true
|
CONTINUOUS_INTEGRATION: true
|
||||||
- name: Create conf/config.sh
|
- name: Create conf/config.sh
|
||||||
run: source ./apps/ci/ci-conf-core.sh
|
run: source ./apps/ci/ci-conf-core.sh
|
||||||
|
- name: Process pending sql
|
||||||
|
run: bash bin/acore-db-pendings
|
||||||
- name: Build
|
- name: Build
|
||||||
run: source ./apps/ci/ci-compile.sh
|
run: source ./apps/ci/ci-compile.sh
|
||||||
- name: Dry run
|
- name: Dry run
|
||||||
|
|||||||
2
.github/workflows/core_modules_build.yml
vendored
2
.github/workflows/core_modules_build.yml
vendored
@ -43,6 +43,8 @@ jobs:
|
|||||||
CONTINUOUS_INTEGRATION: true
|
CONTINUOUS_INTEGRATION: true
|
||||||
- name: Create conf/config.sh
|
- name: Create conf/config.sh
|
||||||
run: source ./apps/ci/ci-conf-core.sh
|
run: source ./apps/ci/ci-conf-core.sh
|
||||||
|
- name: Process pending sql
|
||||||
|
run: bash bin/acore-db-pendings
|
||||||
- name: Build
|
- name: Build
|
||||||
run: source ./apps/ci/ci-compile.sh
|
run: source ./apps/ci/ci-compile.sh
|
||||||
- name: Dry run
|
- name: Dry run
|
||||||
|
|||||||
46
.github/workflows/tools_build.yml
vendored
Normal file
46
.github/workflows/tools_build.yml
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
name: tools
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.head_ref }} || concat(${{ github.ref }}, ${{ github.workflow }})
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
# the result of the matrix will be the combination of all attributes, so we get os*compiler builds
|
||||||
|
os: [ubuntu-20.04]
|
||||||
|
compiler: [clang]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
name: ${{ matrix.os }}-${{ matrix.compiler }}
|
||||||
|
env:
|
||||||
|
COMPILER: ${{ matrix.compiler }}
|
||||||
|
if: github.repository == 'azerothcore/azerothcore-wotlk'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
env:
|
||||||
|
cache-name: cache-tools
|
||||||
|
with:
|
||||||
|
path: var/ccache
|
||||||
|
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.ref }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.ref }}-
|
||||||
|
${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.compiler }}-
|
||||||
|
${{ env.cache-name }}-${{ matrix.os }}-
|
||||||
|
- name: Configure OS
|
||||||
|
run: source ./acore.sh install-deps
|
||||||
|
env:
|
||||||
|
CONTINUOUS_INTEGRATION: true
|
||||||
|
- name: Create conf/config.sh
|
||||||
|
run: source ./apps/ci/ci-conf-tools.sh
|
||||||
|
- name: Build
|
||||||
|
run: source ./apps/ci/ci-compile.sh
|
||||||
|
|
||||||
4
.github/workflows/windows_build.yml
vendored
4
.github/workflows/windows_build.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest]
|
os: [windows-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
name: ${{ matrix.os }}-${{ matrix.compiler }}
|
name: ${{ matrix.os }}
|
||||||
env:
|
env:
|
||||||
BOOST_ROOT: C:\local\boost_1_79_0
|
BOOST_ROOT: C:\local\boost_1_79_0
|
||||||
if: github.repository == 'azerothcore/azerothcore-wotlk' && (github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'run-build') || github.event.label.name == 'run-build')
|
if: github.repository == 'azerothcore/azerothcore-wotlk' && (github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'run-build') || github.event.label.name == 'run-build')
|
||||||
@ -29,7 +29,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
mkdir -p build && cd build
|
mkdir -p build && cd build
|
||||||
cmake .. -DTOOLS=ON
|
cmake .. -DTOOLS_BUILD=all
|
||||||
cmake --build . --config Release --parallel 4
|
cmake --build . --config Release --parallel 4
|
||||||
- name: Copy dll files
|
- name: Copy dll files
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@ -7,8 +7,9 @@ MTHREADS=$(($(grep -c ^processor /proc/cpuinfo) + 2))
|
|||||||
CWARNINGS=ON
|
CWARNINGS=ON
|
||||||
CDEBUG=OFF
|
CDEBUG=OFF
|
||||||
CTYPE=Release
|
CTYPE=Release
|
||||||
CTOOLS_BUILD=all
|
CTOOLS_BUILD=none
|
||||||
CSCRIPTS=static
|
CSCRIPTS=static
|
||||||
|
CMODULES=static
|
||||||
CBUILD_TESTING=ON
|
CBUILD_TESTING=ON
|
||||||
CSCRIPTPCH=OFF
|
CSCRIPTPCH=OFF
|
||||||
CCOREPCH=OFF
|
CCOREPCH=OFF
|
||||||
|
|||||||
39
apps/ci/ci-conf-db.sh
Normal file
39
apps/ci/ci-conf-db.sh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cat >>conf/config.sh <<CONFIG_SH
|
||||||
|
MTHREADS=$(($(grep -c ^processor /proc/cpuinfo) + 2))
|
||||||
|
CWARNINGS=ON
|
||||||
|
CDEBUG=OFF
|
||||||
|
CTYPE=Release
|
||||||
|
CAPPS_BUILD=none
|
||||||
|
CTOOLS_BUILD=db-only
|
||||||
|
CSCRIPTPCH=OFF
|
||||||
|
CCOREPCH=OFF
|
||||||
|
CCUSTOMOPTIONS='-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror"'
|
||||||
|
DB_CHARACTERS_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
|
||||||
|
DB_AUTH_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
|
||||||
|
DB_WORLD_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
|
||||||
|
CONFIG_SH
|
||||||
|
|
||||||
|
case $COMPILER in
|
||||||
|
|
||||||
|
# this is in order to use the "default" clang version of the OS, without forcing a specific version
|
||||||
|
"clang" )
|
||||||
|
time sudo apt-get install -y clang
|
||||||
|
echo "CCOMPILERC=\"clang\"" >> ./conf/config.sh
|
||||||
|
echo "CCOMPILERCXX=\"clang++\"" >> ./conf/config.sh
|
||||||
|
;;
|
||||||
|
|
||||||
|
"clang12" )
|
||||||
|
time sudo apt-get install -y clang-12
|
||||||
|
echo "CCOMPILERC=\"clang-12\"" >> ./conf/config.sh
|
||||||
|
echo "CCOMPILERCXX=\"clang++-12\"" >> ./conf/config.sh
|
||||||
|
;;
|
||||||
|
|
||||||
|
* )
|
||||||
|
echo "Unknown compiler $COMPILER"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@ -7,7 +7,6 @@ MTHREADS=$(($(grep -c ^processor /proc/cpuinfo) + 2))
|
|||||||
CWARNINGS=ON
|
CWARNINGS=ON
|
||||||
CDEBUG=OFF
|
CDEBUG=OFF
|
||||||
CTYPE=Release
|
CTYPE=Release
|
||||||
CSCRIPTS=static
|
|
||||||
CAPPS_BUILD=none
|
CAPPS_BUILD=none
|
||||||
CTOOLS_BUILD=maps-only
|
CTOOLS_BUILD=maps-only
|
||||||
CSCRIPTPCH=OFF
|
CSCRIPTPCH=OFF
|
||||||
|
|||||||
3
conf/dist/config.cmake
vendored
3
conf/dist/config.cmake
vendored
@ -14,8 +14,7 @@
|
|||||||
set(SCRIPTS_AVAILABLE_OPTIONS none static dynamic minimal-static minimal-dynamic)
|
set(SCRIPTS_AVAILABLE_OPTIONS none static dynamic minimal-static minimal-dynamic)
|
||||||
set(MODULES_AVAILABLE_OPTIONS none static dynamic)
|
set(MODULES_AVAILABLE_OPTIONS none static dynamic)
|
||||||
set(BUILD_APPS_AVAILABLE_OPTIONS none all auth-only world-only)
|
set(BUILD_APPS_AVAILABLE_OPTIONS none all auth-only world-only)
|
||||||
# set(BUILD_TOOLS_AVAILABLE_OPTIONS none all db-only maps-only) # DB import PR
|
set(BUILD_TOOLS_AVAILABLE_OPTIONS none all db-only maps-only)
|
||||||
set(BUILD_TOOLS_AVAILABLE_OPTIONS none all maps-only)
|
|
||||||
|
|
||||||
set(SCRIPTS "static" CACHE STRING "Build core with scripts")
|
set(SCRIPTS "static" CACHE STRING "Build core with scripts")
|
||||||
set(MODULES "static" CACHE STRING "Build core with modules")
|
set(MODULES "static" CACHE STRING "Build core with modules")
|
||||||
|
|||||||
3
deps/CMakeLists.txt
vendored
3
deps/CMakeLists.txt
vendored
@ -26,8 +26,7 @@ add_subdirectory(stdfs)
|
|||||||
add_subdirectory(threads)
|
add_subdirectory(threads)
|
||||||
add_subdirectory(utf8cpp)
|
add_subdirectory(utf8cpp)
|
||||||
|
|
||||||
# if ((APPS_BUILD AND (NOT APPS_BUILD STREQUAL "none")) OR BUILD_TOOLS_DB_IMPORT) #DB import PR
|
if ((APPS_BUILD AND (NOT APPS_BUILD STREQUAL "none")) OR BUILD_TOOLS_DB_IMPORT)
|
||||||
if ((APPS_BUILD AND (NOT APPS_BUILD STREQUAL "none")))
|
|
||||||
add_subdirectory(mysql)
|
add_subdirectory(mysql)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,6 @@
|
|||||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
#
|
#
|
||||||
|
|
||||||
message("")
|
|
||||||
|
|
||||||
# Make the script module list available in the current scope
|
# Make the script module list available in the current scope
|
||||||
GetModuleSourceList(MODULES_MODULE_LIST)
|
GetModuleSourceList(MODULES_MODULE_LIST)
|
||||||
|
|
||||||
@ -290,7 +288,7 @@ target_include_directories(modules
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${PUBLIC_INCLUDES})
|
${PUBLIC_INCLUDES})
|
||||||
|
|
||||||
set_target_properties(scripts
|
set_target_properties(modules
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
FOLDER
|
FOLDER
|
||||||
"modules")
|
"modules")
|
||||||
|
|||||||
@ -75,9 +75,9 @@ function(CheckToolsBuildList)
|
|||||||
list(APPEND BUILD_TOOLS_WHITELIST map_extractor mmaps_generator vmap4_assembler vmap4_extractor)
|
list(APPEND BUILD_TOOLS_WHITELIST map_extractor mmaps_generator vmap4_assembler vmap4_extractor)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# if (TOOLS_BUILD STREQUAL "db-only")
|
if (TOOLS_BUILD STREQUAL "db-only")
|
||||||
# list(APPEND BUILD_TOOLS_WHITELIST dbimport)
|
list(APPEND BUILD_TOOLS_WHITELIST dbimport)
|
||||||
# endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set the TOOL_${TOOL_BUILD_NAME} variables from the
|
# Set the TOOL_${TOOL_BUILD_NAME} variables from the
|
||||||
|
|||||||
@ -12,8 +12,7 @@
|
|||||||
|
|
||||||
add_subdirectory(apps)
|
add_subdirectory(apps)
|
||||||
|
|
||||||
# if ((APPS_BUILD AND NOT APPS_BUILD STREQUAL "none") OR BUILD_TOOLS_DB_IMPORT) # DB import PR
|
if ((APPS_BUILD AND NOT APPS_BUILD STREQUAL "none") OR BUILD_TOOLS_DB_IMPORT)
|
||||||
if ((APPS_BUILD AND NOT APPS_BUILD STREQUAL "none"))
|
|
||||||
add_subdirectory(database)
|
add_subdirectory(database)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@ -56,11 +56,6 @@ foreach(BUILD_APP ${APPLICATIONS_BUILD_LIST})
|
|||||||
set(BUILD_APP_VALUE_DISPLAY_apps apps)
|
set(BUILD_APP_VALUE_DISPLAY_apps apps)
|
||||||
list(APPEND BUILD_APP_VALUE_CONTAINS_apps ${BUILD_APP})
|
list(APPEND BUILD_APP_VALUE_CONTAINS_apps ${BUILD_APP})
|
||||||
|
|
||||||
if (${BUILD_APP} MATCHES "authserver")
|
|
||||||
set (BUILD_APPLICATION_AUTHSERVER 1)
|
|
||||||
elseif(${BUILD_APP} MATCHES "worldserver")
|
|
||||||
set (BUILD_APPLICATION_WORLDSERVER 1)
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
list(APPEND BUILD_APP_GRAPH_KEYS disabled)
|
list(APPEND BUILD_APP_GRAPH_KEYS disabled)
|
||||||
set(BUILD_APP_VALUE_DISPLAY_disabled disabled)
|
set(BUILD_APP_VALUE_DISPLAY_disabled disabled)
|
||||||
|
|||||||
@ -27,9 +27,9 @@ if (TOOLS_BUILD MATCHES "-only")
|
|||||||
list(APPEND BUILD_TOOLS_WHITELIST map_extractor mmaps_generator vmap4_assembler vmap4_extractor)
|
list(APPEND BUILD_TOOLS_WHITELIST map_extractor mmaps_generator vmap4_assembler vmap4_extractor)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# if (TOOLS_BUILD STREQUAL "db-only")
|
if (TOOLS_BUILD STREQUAL "db-only")
|
||||||
# list(APPEND BUILD_TOOLS_WHITELIST dbimport)
|
list(APPEND BUILD_TOOLS_WHITELIST dbimport)
|
||||||
# endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set the TOOL_${TOOL_BUILD_NAME} variables from the
|
# Set the TOOL_${TOOL_BUILD_NAME} variables from the
|
||||||
@ -66,7 +66,7 @@ list(SORT TOOL_BUILD_GRAPH_KEYS)
|
|||||||
list(REMOVE_DUPLICATES TOOL_BUILD_GRAPH_KEYS)
|
list(REMOVE_DUPLICATES TOOL_BUILD_GRAPH_KEYS)
|
||||||
|
|
||||||
# Display the graphs
|
# Display the graphs
|
||||||
# message("")
|
message("")
|
||||||
message("* Tools build list (${TOOLS_BUILD}):")
|
message("* Tools build list (${TOOLS_BUILD}):")
|
||||||
message(" |")
|
message(" |")
|
||||||
|
|
||||||
@ -112,19 +112,26 @@ foreach(TOOL_NAME ${TOOLS_BUILD_LIST})
|
|||||||
|
|
||||||
add_dependencies(${TOOL_PROJECT_NAME} revision.h)
|
add_dependencies(${TOOL_PROJECT_NAME} revision.h)
|
||||||
|
|
||||||
# Need fix errors
|
# Need fix errors in maps tools
|
||||||
# target_link_libraries(${TOOL_PROJECT_NAME}
|
# target_link_libraries(${TOOL_PROJECT_NAME}
|
||||||
# PRIVATE
|
# PRIVATE
|
||||||
# acore-core-interface)
|
# acore-dependency-interface)
|
||||||
|
|
||||||
# if (${TOOL_PROJECT_NAME} MATCHES "dbimport")
|
if (${TOOL_PROJECT_NAME} MATCHES "dbimport")
|
||||||
# target_link_libraries(${TOOL_PROJECT_NAME}
|
target_link_libraries(${TOOL_PROJECT_NAME}
|
||||||
# PUBLIC
|
PUBLIC
|
||||||
# database)
|
database
|
||||||
|
PRIVATE
|
||||||
|
acore-core-interface)
|
||||||
|
|
||||||
|
# Install config
|
||||||
|
CopyToolConfig(${TOOL_PROJECT_NAME} ${TOOL_NAME})
|
||||||
|
else()
|
||||||
|
|
||||||
|
target_link_libraries(${TOOL_PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
acore-dependency-interface)
|
||||||
|
|
||||||
# # Install config
|
|
||||||
# CopyToolConfig(${TOOL_PROJECT_NAME} ${TOOL_NAME})
|
|
||||||
# else()
|
|
||||||
target_link_libraries(${TOOL_PROJECT_NAME}
|
target_link_libraries(${TOOL_PROJECT_NAME}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
common
|
common
|
||||||
@ -132,7 +139,7 @@ foreach(TOOL_NAME ${TOOLS_BUILD_LIST})
|
|||||||
zlib
|
zlib
|
||||||
Recast
|
Recast
|
||||||
g3dlib)
|
g3dlib)
|
||||||
# endif()
|
endif()
|
||||||
|
|
||||||
unset(TOOL_PUBLIC_INCLUDES)
|
unset(TOOL_PUBLIC_INCLUDES)
|
||||||
CollectIncludeDirectories(
|
CollectIncludeDirectories(
|
||||||
|
|||||||
151
src/tools/dbimport/Main.cpp
Normal file
151
src/tools/dbimport/Main.cpp
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Affero General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Banner.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include "Config.h"
|
||||||
|
#include "DatabaseEnv.h"
|
||||||
|
#include "DatabaseLoader.h"
|
||||||
|
#include "IoContext.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include "MySQLThreading.h"
|
||||||
|
#include "Util.h"
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
|
#include <boost/version.hpp>
|
||||||
|
#include <csignal>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <iostream>
|
||||||
|
#include <openssl/crypto.h>
|
||||||
|
#include <openssl/opensslv.h>
|
||||||
|
|
||||||
|
#ifndef _ACORE_DB_IMPORT_CONFIG
|
||||||
|
#define _ACORE_DB_IMPORT_CONFIG "dbimport.conf"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace boost::program_options;
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
bool StartDB();
|
||||||
|
void StopDB();
|
||||||
|
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile);
|
||||||
|
|
||||||
|
/// Launch the db import server
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
signal(SIGABRT, &Acore::AbortHandler);
|
||||||
|
|
||||||
|
// Command line parsing
|
||||||
|
auto configFile = fs::path(sConfigMgr->GetConfigPath() + std::string(_ACORE_DB_IMPORT_CONFIG));
|
||||||
|
auto vm = GetConsoleArguments(argc, argv, configFile);
|
||||||
|
|
||||||
|
// exit if help is enabled
|
||||||
|
if (vm.count("help"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Add file and args in config
|
||||||
|
sConfigMgr->Configure(configFile.generic_string(), std::vector<std::string>(argv, argv + argc));
|
||||||
|
|
||||||
|
if (!sConfigMgr->LoadAppConfigs())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Init logging
|
||||||
|
sLog->Initialize();
|
||||||
|
|
||||||
|
Acore::Banner::Show("dbimport",
|
||||||
|
[](std::string_view text)
|
||||||
|
{
|
||||||
|
LOG_INFO("dbimport", text);
|
||||||
|
},
|
||||||
|
[]()
|
||||||
|
{
|
||||||
|
LOG_INFO("dbimport", "> Using configuration file: {}", sConfigMgr->GetFilename());
|
||||||
|
LOG_INFO("dbimport", "> Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||||
|
LOG_INFO("dbimport", "> Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initialize the database connection
|
||||||
|
if (!StartDB())
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
std::shared_ptr<void> dbHandle(nullptr, [](void*) { StopDB(); });
|
||||||
|
|
||||||
|
LOG_INFO("dbimport", "Halting process...");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initialize connection to the database
|
||||||
|
bool StartDB()
|
||||||
|
{
|
||||||
|
MySQL::Library_Init();
|
||||||
|
|
||||||
|
// Load databases
|
||||||
|
DatabaseLoader loader("dbimport");
|
||||||
|
loader
|
||||||
|
.AddDatabase(LoginDatabase, "Login")
|
||||||
|
.AddDatabase(CharacterDatabase, "Character")
|
||||||
|
.AddDatabase(WorldDatabase, "World");
|
||||||
|
|
||||||
|
if (!loader.Load())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LOG_INFO("dbimport", "Started database connection pool.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Close the connection to the database
|
||||||
|
void StopDB()
|
||||||
|
{
|
||||||
|
CharacterDatabase.Close();
|
||||||
|
WorldDatabase.Close();
|
||||||
|
LoginDatabase.Close();
|
||||||
|
MySQL::Library_End();
|
||||||
|
}
|
||||||
|
|
||||||
|
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile)
|
||||||
|
{
|
||||||
|
options_description all("Allowed options");
|
||||||
|
all.add_options()
|
||||||
|
("help,h", "print usage message")
|
||||||
|
("version,v", "print version build info")
|
||||||
|
("dry-run,d", "Dry run")
|
||||||
|
("config,c", value<fs::path>(&configFile)->default_value(fs::path(sConfigMgr->GetConfigPath() + std::string(_ACORE_DB_IMPORT_CONFIG))), "use <arg> as configuration file");
|
||||||
|
|
||||||
|
variables_map variablesMap;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
store(command_line_parser(argc, argv).options(all).allow_unregistered().run(), variablesMap);
|
||||||
|
notify(variablesMap);
|
||||||
|
}
|
||||||
|
catch (std::exception const& e)
|
||||||
|
{
|
||||||
|
std::cerr << e.what() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variablesMap.count("help"))
|
||||||
|
{
|
||||||
|
std::cout << all << "\n";
|
||||||
|
}
|
||||||
|
else if (variablesMap.count("dry-run"))
|
||||||
|
{
|
||||||
|
sConfigMgr->setDryRun(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return variablesMap;
|
||||||
|
}
|
||||||
286
src/tools/dbimport/dbimport.conf.dist
Normal file
286
src/tools/dbimport/dbimport.conf.dist
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
##################################################
|
||||||
|
# AzerothCore Database Import configuration file #
|
||||||
|
##################################################
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
# SECTION INDEX
|
||||||
|
#
|
||||||
|
# EXAMPLE CONFIG
|
||||||
|
# DB IMPORT CONFIG
|
||||||
|
# MYSQL SETTINGS
|
||||||
|
# UPDATE SETTINGS
|
||||||
|
# LOGGING SYSTEM SETTINGS
|
||||||
|
#
|
||||||
|
###################################################################################################
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
# EXAMPLE CONFIG
|
||||||
|
#
|
||||||
|
# Variable
|
||||||
|
# Description: Brief description what the variable is doing.
|
||||||
|
# Important: Annotation for important things about this variable.
|
||||||
|
# Example: "Example, i.e. if the value is a string"
|
||||||
|
# Default: 10 - (Enabled|Comment|Variable name in case of grouped config options)
|
||||||
|
# 0 - (Disabled|Comment|Variable name in case of grouped config options)
|
||||||
|
#
|
||||||
|
# Note to developers:
|
||||||
|
# - Copy this example to keep the formatting.
|
||||||
|
# - Line breaks should be at column 100.
|
||||||
|
###################################################################################################
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
# DB IMPORT CONFIG
|
||||||
|
#
|
||||||
|
# LogsDir
|
||||||
|
# Description: Logs directory setting.
|
||||||
|
# Important: LogsDir needs to be quoted, as the string might contain space characters.
|
||||||
|
# Logs directory must exists, or log file creation will be disabled.
|
||||||
|
# Example: "/home/youruser/azerothcore/logs"
|
||||||
|
# Default: "" - (Log files will be stored in the current path)
|
||||||
|
|
||||||
|
LogsDir = ""
|
||||||
|
|
||||||
|
#
|
||||||
|
# SourceDirectory
|
||||||
|
# Description: The path to your AzerothCore source directory.
|
||||||
|
# If the path is left empty, the built-in CMAKE_SOURCE_DIR is used.
|
||||||
|
# Example: "../AzerothCore"
|
||||||
|
# Default: ""
|
||||||
|
#
|
||||||
|
|
||||||
|
SourceDirectory = ""
|
||||||
|
|
||||||
|
#
|
||||||
|
# MySQLExecutable
|
||||||
|
# Description: The path to your MySQL CLI binary.
|
||||||
|
# If the path is left empty, built-in path from cmake is used.
|
||||||
|
# Example: "C:/Program Files/MariaDB 10.9/bin/mysql.exe"
|
||||||
|
# "mysql.exe"
|
||||||
|
# "/usr/bin/mysql"
|
||||||
|
# Default: ""
|
||||||
|
#
|
||||||
|
|
||||||
|
MySQLExecutable = ""
|
||||||
|
###################################################################################################
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
# MYSQL SETTINGS
|
||||||
|
#
|
||||||
|
# LoginDatabaseInfo
|
||||||
|
# WorldDatabaseInfo
|
||||||
|
# CharacterDatabaseInfo
|
||||||
|
# Description: Database connection settings for the world server.
|
||||||
|
# Example: "hostname;port;username;password;database"
|
||||||
|
# ".;somenumber;username;password;database" - (Use named pipes on Windows
|
||||||
|
# "enable-named-pipe" to [mysqld]
|
||||||
|
# section my.ini)
|
||||||
|
# ".;/path/to/unix_socket;username;password;database;ssl" - (use Unix sockets on
|
||||||
|
# Unix/Linux)
|
||||||
|
# Default: "127.0.0.1;3306;acore;acore;acore_auth" - (LoginDatabaseInfo)
|
||||||
|
# "127.0.0.1;3306;acore;acore;acore_world" - (WorldDatabaseInfo)
|
||||||
|
# "127.0.0.1;3306;acore;acore;acore_characters" - (CharacterDatabaseInfo)
|
||||||
|
#
|
||||||
|
# The SSL option will enable TLS when connecting to the specified database. If not provided or
|
||||||
|
# any value other than 'ssl' is set, TLS will not be used.
|
||||||
|
#
|
||||||
|
|
||||||
|
LoginDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_auth"
|
||||||
|
WorldDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_world"
|
||||||
|
CharacterDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_characters"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Database.Reconnect.Seconds
|
||||||
|
# Database.Reconnect.Attempts
|
||||||
|
#
|
||||||
|
# Description: How many seconds between every reconnection attempt
|
||||||
|
# and how many attempts will be performed in total
|
||||||
|
# Default: 20 attempts every 15 seconds
|
||||||
|
#
|
||||||
|
|
||||||
|
Database.Reconnect.Seconds = 5
|
||||||
|
Database.Reconnect.Attempts = 5
|
||||||
|
|
||||||
|
#
|
||||||
|
# LoginDatabase.WorkerThreads
|
||||||
|
# WorldDatabase.WorkerThreads
|
||||||
|
# CharacterDatabase.WorkerThreads
|
||||||
|
# Description: The amount of worker threads spawned to handle asynchronous (delayed) MySQL
|
||||||
|
# statements. Each worker thread is mirrored with its own connection to the
|
||||||
|
# MySQL server and their own thread on the MySQL server.
|
||||||
|
# Default: 1 - (LoginDatabase.WorkerThreads)
|
||||||
|
# 1 - (WorldDatabase.WorkerThreads)
|
||||||
|
# 1 - (CharacterDatabase.WorkerThreads)
|
||||||
|
#
|
||||||
|
|
||||||
|
LoginDatabase.WorkerThreads = 1
|
||||||
|
WorldDatabase.WorkerThreads = 1
|
||||||
|
CharacterDatabase.WorkerThreads = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# LoginDatabase.SynchThreads
|
||||||
|
# WorldDatabase.SynchThreads
|
||||||
|
# CharacterDatabase.SynchThreads
|
||||||
|
# Description: The amount of MySQL connections spawned to handle.
|
||||||
|
# Default: 1 - (LoginDatabase.WorkerThreads)
|
||||||
|
# 1 - (WorldDatabase.WorkerThreads)
|
||||||
|
# 1 - (CharacterDatabase.WorkerThreads)
|
||||||
|
#
|
||||||
|
|
||||||
|
LoginDatabase.SynchThreads = 1
|
||||||
|
WorldDatabase.SynchThreads = 1
|
||||||
|
CharacterDatabase.SynchThreads = 1
|
||||||
|
###################################################################################################
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
# UPDATE SETTINGS
|
||||||
|
#
|
||||||
|
# Updates.EnableDatabases
|
||||||
|
# Description: A mask that describes which databases shall be updated.
|
||||||
|
#
|
||||||
|
# Following flags are available
|
||||||
|
# DATABASE_LOGIN = 1, // Auth database
|
||||||
|
# DATABASE_CHARACTER = 2, // Character database
|
||||||
|
# DATABASE_WORLD = 4, // World database
|
||||||
|
#
|
||||||
|
# Default: 7 - (All enabled)
|
||||||
|
# 4 - (Enable world only)
|
||||||
|
# 0 - (All disabled)
|
||||||
|
|
||||||
|
Updates.EnableDatabases = 7
|
||||||
|
|
||||||
|
#
|
||||||
|
# Updates.AutoSetup
|
||||||
|
# Description: Auto populate empty databases.
|
||||||
|
# Default: 1 - (Enabled)
|
||||||
|
# 0 - (Disabled)
|
||||||
|
|
||||||
|
Updates.AutoSetup = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# Updates.Redundancy
|
||||||
|
# Description: Perform data redundancy checks through hashing
|
||||||
|
# to detect changes on sql updates and reapply it.
|
||||||
|
# Default: 1 - (Enabled)
|
||||||
|
# 0 - (Disabled)
|
||||||
|
|
||||||
|
Updates.Redundancy = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# Updates.ArchivedRedundancy
|
||||||
|
# Description: Check hashes of archived updates (slows down startup).
|
||||||
|
# Default: 0 - (Disabled)
|
||||||
|
# 1 - (Enabled)
|
||||||
|
|
||||||
|
Updates.ArchivedRedundancy = 0
|
||||||
|
|
||||||
|
#
|
||||||
|
# Updates.AllowRehash
|
||||||
|
# Description: Inserts the current file hash in the database if it is left empty.
|
||||||
|
# Useful if you want to mark a file as applied but you don't know its hash.
|
||||||
|
# Default: 1 - (Enabled)
|
||||||
|
# 0 - (Disabled)
|
||||||
|
|
||||||
|
Updates.AllowRehash = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# Updates.CleanDeadRefMaxCount
|
||||||
|
# Description: Cleans dead/ orphaned references that occur if an update was removed or renamed and edited in one step.
|
||||||
|
# It only starts the clean up if the count of the missing updates is below or equal the Updates.CleanDeadRefMaxCount value.
|
||||||
|
# This way prevents erasing of the update history due to wrong source directory state (maybe wrong branch or bad revision).
|
||||||
|
# Disable this if you want to know if the database is in a possible "dirty state".
|
||||||
|
# Default: 3 - (Enabled)
|
||||||
|
# 0 - (Disabled)
|
||||||
|
# -1 - (Enabled - unlimited)
|
||||||
|
|
||||||
|
Updates.CleanDeadRefMaxCount = 3
|
||||||
|
###################################################################################################
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
|
#
|
||||||
|
# LOGGING SYSTEM SETTINGS
|
||||||
|
#
|
||||||
|
# Appender config values: Given an appender "name"
|
||||||
|
# Appender.name
|
||||||
|
# Description: Defines 'where to log'
|
||||||
|
# Format: Type,LogLevel,Flags,optional1,optional2,optional3
|
||||||
|
#
|
||||||
|
# Type
|
||||||
|
# 0 - (None)
|
||||||
|
# 1 - (Console)
|
||||||
|
# 2 - (File)
|
||||||
|
# 3 - (DB)
|
||||||
|
#
|
||||||
|
# LogLevel
|
||||||
|
# 0 - (Disabled)
|
||||||
|
# 1 - (Fatal)
|
||||||
|
# 2 - (Error)
|
||||||
|
# 3 - (Warning)
|
||||||
|
# 4 - (Info)
|
||||||
|
# 5 - (Debug)
|
||||||
|
# 6 - (Trace)
|
||||||
|
#
|
||||||
|
# Flags:
|
||||||
|
# 0 - None
|
||||||
|
# 1 - Prefix Timestamp to the text
|
||||||
|
# 2 - Prefix Log Level to the text
|
||||||
|
# 4 - Prefix Log Filter type to the text
|
||||||
|
# 8 - Append timestamp to the log file name. Format: YYYY-MM-DD_HH-MM-SS (Only used with Type = 2)
|
||||||
|
# 16 - Make a backup of existing file before overwrite (Only used with Mode = w)
|
||||||
|
#
|
||||||
|
# Colors (read as optional1 if Type = Console)
|
||||||
|
# Format: "fatal error warn info debug trace"
|
||||||
|
# 0 - BLACK
|
||||||
|
# 1 - RED
|
||||||
|
# 2 - GREEN
|
||||||
|
# 3 - BROWN
|
||||||
|
# 4 - BLUE
|
||||||
|
# 5 - MAGENTA
|
||||||
|
# 6 - CYAN
|
||||||
|
# 7 - GREY
|
||||||
|
# 8 - YELLOW
|
||||||
|
# 9 - LRED
|
||||||
|
# 10 - LGREEN
|
||||||
|
# 11 - LBLUE
|
||||||
|
# 12 - LMAGENTA
|
||||||
|
# 13 - LCYAN
|
||||||
|
# 14 - WHITE
|
||||||
|
# Example: "1 9 3 6 5 8"
|
||||||
|
#
|
||||||
|
# File: Name of the file (read as optional1 if Type = File)
|
||||||
|
# Allows to use one "%s" to create dynamic files
|
||||||
|
#
|
||||||
|
# Mode: Mode to open the file (read as optional2 if Type = File)
|
||||||
|
# a - (Append)
|
||||||
|
# w - (Overwrite)
|
||||||
|
#
|
||||||
|
# MaxFileSize: Maximum file size of the log file before creating a new log file
|
||||||
|
# (read as optional3 if Type = File)
|
||||||
|
# Size is measured in bytes expressed in a 64-bit unsigned integer.
|
||||||
|
# Maximum value is 4294967295 (4 GB). Leave blank for no limit.
|
||||||
|
# NOTE: Does not work with dynamic filenames.
|
||||||
|
# Example: 536870912 (512 MB)
|
||||||
|
#
|
||||||
|
|
||||||
|
Appender.Console=1,5,0,"1 9 3 6 5 8"
|
||||||
|
Appender.DBImport=2,5,0,DBImport.log,w
|
||||||
|
|
||||||
|
# Logger config values: Given a logger "name"
|
||||||
|
# Logger.name
|
||||||
|
# Description: Defines 'What to log'
|
||||||
|
# Format: LogLevel,AppenderList
|
||||||
|
#
|
||||||
|
# LogLevel
|
||||||
|
# 0 - (Disabled)
|
||||||
|
# 1 - (Fatal)
|
||||||
|
# 2 - (Error)
|
||||||
|
# 3 - (Warning)
|
||||||
|
# 4 - (Info)
|
||||||
|
# 5 - (Debug)
|
||||||
|
# 6 - (Trace)
|
||||||
|
#
|
||||||
|
# AppenderList: List of appenders linked to logger
|
||||||
|
# (Using spaces as separator).
|
||||||
|
#
|
||||||
|
|
||||||
|
Logger.root=4,Console DBImport
|
||||||
|
###################################################################################################
|
||||||
Loading…
x
Reference in New Issue
Block a user