<commit_before>/*
* AscEmu Framework based on ArcEmu MMORPG Server
* Copyright (c) 2014-2018 AscEmu Team <http://www.ascemu.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* 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 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 "LogonStdAfx.h"
#include <Threading/AEThreadPool.h>

using AscEmu::Threading::AEThread;
using AscEmu::Threading::AEThreadPool;
using std::chrono::milliseconds;

// Database impl
Database* sLogonSQL;
initialiseSingleton(LogonServer);
std::atomic<bool> mrunning(true);
Mutex _authSocketLock;
std::set<AuthSocket*> _authSockets;

ConfigMgr Config;

void LogonServer::Run(int /*argc*/, char** /*argv*/)
{
    UNIXTIME = time(NULL);
    g_localTime = *localtime(&UNIXTIME);

    AscLog.InitalizeLogFiles("logon");

    PrintBanner();

    LogDefault("The key combination <Ctrl-C> will safely shut down the server.");

    LogDetail("Config : Loading Config Files...");
    if (!LoadLogonConfiguration())
    {
        AscLog.~AscEmuLog();
        return;
    }

    AscLog.SetFileLoggingLevel(Config.MainConfig.getIntDefault("LogLevel", "File", 0));

    LogDetail("ThreadMgr : Starting...");
    ThreadPool.Startup();

    if (!StartDb())
    {
        AscLog.~AscEmuLog();
        return;
    }

    LogDetail("AccountMgr : Starting...");
    new AccountMgr;
    new IPBanner;

    LogDetail("InfoCore : Starting...");
    new InformationCore;

    new PatchMgr;
    LogNotice("AccountMgr : Precaching accounts...");
    sAccountMgr.ReloadAccounts(true);
    LogDetail("AccountMgr : %u accounts are loaded and ready.", sAccountMgr.GetCount());

    // Spawn periodic function caller thread for account reload every 10mins
    uint32 accountReloadPeriod = Config.MainConfig.getIntDefault("Rates", "AccountRefresh", 600);
    accountReloadPeriod *= 1000;

    PeriodicFunctionCaller<AccountMgr> * periodicReloadAccounts = new PeriodicFunctionCaller<AccountMgr>(AccountMgr::getSingletonPtr(), &AccountMgr::ReloadAccountsCallback, accountReloadPeriod);
    ThreadPool.ExecuteTask(periodicReloadAccounts);
    AEThreadPool::globalThreadPool()->queueRecurringTask([](AEThread&) {AccountMgr::getSingletonPtr()->ReloadAccountsCallback();}, milliseconds(accountReloadPeriod), "Reload Accounts");

    // Load conf settings..
    uint32 realmlistPort = Config.MainConfig.getIntDefault("Listen", "RealmListPort", 3724);
    uint32 logonServerPort = Config.MainConfig.getIntDefault("Listen", "ServerPort", 8093);

    std::string host = Config.MainConfig.getStringDefault("Listen", "Host", "0.0.0.0");
    std::string shost = Config.MainConfig.getStringDefault("Listen", "ISHost", host.c_str());

    clientMinBuild = 5875;
    clientMaxBuild = 15595;

    std::string logonServerPassword = Config.MainConfig.getStringDefault("LogonServer", "RemotePassword", "<PASSWORD>");<commit_msg>Comment out leftover test code<commit_after>/*
* AscEmu Framework based on ArcEmu MMORPG Server
* Copyright (c) 2014-2018 AscEmu Team <http://www.ascemu.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* 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 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 "LogonStdAfx.h"
#include <Threading/AEThreadPool.h>

using AscEmu::Threading::AEThread;
using AscEmu::Threading::AEThreadPool;
using std::chrono::milliseconds;

// Database impl
Database* sLogonSQL;
initialiseSingleton(LogonServer);
std::atomic<bool> mrunning(true);
Mutex _authSocketLock;
std::set<AuthSocket*> _authSockets;

ConfigMgr Config;

void LogonServer::Run(int /*argc*/, char** /*argv*/)
{
    UNIXTIME = time(NULL);
    g_localTime = *localtime(&UNIXTIME);

    AscLog.InitalizeLogFiles("logon");

    PrintBanner();

    LogDefault("The key combination <Ctrl-C> will safely shut down the server.");

    LogDetail("Config : Loading Config Files...");
    if (!LoadLogonConfiguration())
    {
        AscLog.~AscEmuLog();
        return;
    }

    AscLog.SetFileLoggingLevel(Config.MainConfig.getIntDefault("LogLevel", "File", 0));

    LogDetail("ThreadMgr : Starting...");
    ThreadPool.Startup();

    if (!StartDb())
    {
        AscLog.~AscEmuLog();
        return;
    }

    LogDetail("AccountMgr : Starting...");
    new AccountMgr;
    new IPBanner;

    LogDetail("InfoCore : Starting...");
    new InformationCore;

    new PatchMgr;
    LogNotice("AccountMgr : Precaching accounts...");
    sAccountMgr.ReloadAccounts(true);
    LogDetail("AccountMgr : %u accounts are loaded and ready.", sAccountMgr.GetCount());

    // Spawn periodic function caller thread for account reload every 10mins
    uint32 accountReloadPeriod = Config.MainConfig.getIntDefault("Rates", "AccountRefresh", 600);
    accountReloadPeriod *= 1000;

    PeriodicFunctionCaller<AccountMgr> * periodicReloadAccounts = new PeriodicFunctionCaller<AccountMgr>(AccountMgr::getSingletonPtr(), &AccountMgr::ReloadAccountsCallback, accountReloadPeriod);
    ThreadPool.ExecuteTask(periodicReloadAccounts);
    //AEThreadPool::globalThreadPool()->queueRecurringTask([](AEThread&) {AccountMgr::getSingletonPtr()->ReloadAccountsCallback();}, milliseconds(accountReloadPeriod), "Reload Accounts");

    // Load conf settings..
    uint32 realmlistPort = Config.MainConfig.getIntDefault("Listen", "RealmListPort", 3724);
    uint32 logonServerPort = Config.MainConfig.getIntDefault("Listen", "ServerPort", 8093);

    std::string host = Config.MainConfig.getStringDefault("Listen", "Host", "0.0.0.0");
    std::string shost = Config.MainConfig.getStringDefault("Listen", "ISHost", host.c_str());

    clientMinBuild = 5875;
    clientMaxBuild = 15595;

    std::string logonServerPassword = Config.MainConfig.getStringDefault("LogonServer", "RemotePassword", "<PASSWORD>");
{'fraction_non_alphanumeric': 0.12251010933053767, 'fraction_numerical': 0.013778643103190056, 'mean_word_length': 4.683404255319149, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '502639', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1944, 'n_words': 517}