44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include "server.h"
|
|
#include "version.h"
|
|
#include <iostream>
|
|
|
|
#ifdef _WIN32
|
|
#include <fcntl.h>
|
|
#include <io.h>
|
|
#include <windows.h>
|
|
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
|
#endif
|
|
#endif
|
|
|
|
Log_t g_Logger = nullptr;
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
g_Logger = get_logger("server");
|
|
#ifdef _WIN32
|
|
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
DWORD mode;
|
|
GetConsoleMode(hConsole, &mode);
|
|
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
|
SetConsoleMode(hConsole, mode);
|
|
#endif
|
|
|
|
g_Logger->info("Build At {} {} under {} on {}", __DATE__, __TIME__, VERSION_GIT_COMMIT,
|
|
VERSION_GIT_BRANCH);
|
|
int port = 9898;
|
|
if (argc < 2) {
|
|
g_Logger->info("Use Default Port:{}", port);
|
|
} else {
|
|
std::string str_port(argv[1]);
|
|
port = std::stoi(str_port);
|
|
g_Logger->info("Use Port:{}", port);
|
|
}
|
|
asio::io_context io_context;
|
|
CTcpServer server(io_context, g_Logger);
|
|
if (!server.start(port)) {
|
|
return -1;
|
|
}
|
|
io_context.run();
|
|
return 0;
|
|
} |