mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-28 20:07:56 +00:00
[CI/CD] Build / Release Pipeline Changes (#2788)
* Test * Test * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * Kill excessive warnings * Split * Remove 7z from build scripts * Linux * Update .drone.yml * Update .drone.yml * Update .drone.yml * Update .drone.yml * Test * Update .drone.yml * Naming * Test upload * Update .drone.yml * Update .drone.yml * Update .drone.yml * Yolo * Yolo * Update .drone.yml * Update .drone.yml * Copy * Yolo * Release without bots * Update .drone.yml * Update .drone.yml * Test pipeline * Remove debug * Update .drone.yml * Filter pipeline stage * Update .drone.yml * Test * Bots release 22.0.5 (Test) * Release bot test #2 * Check if release * Update .drone.yml * Update .drone.yml * exit 78 * Update .drone.yml * Update .drone.yml * Add version checks * Update .drone.yml * Update .drone.yml * Test * Update build-release.bat * Update .drone.yml * Update .drone.yml * Update .drone.yml * Update build-release.bat * Update build-release.bat * Test pipeline * Update CHANGELOG.md * Bump * Update build-release.bat * Update build-release.bat * Shuffle * Take #45354 * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * F * Update windows-build.ps1 * Consolidate * Run it * Pop cache back in * Update linux-build.sh * Another release test * Update linux-build.sh * Update linux-build.sh * Update CMakeLists.txt * Trim windows assets * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * [22.1.0] Release * Crash reporting * Add version tag injection in the build pipeline * Update windows-build.ps1 * Test * Test * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * Kill excessive warnings * Split * Remove 7z from build scripts * Linux * Update .drone.yml * Update .drone.yml * Update .drone.yml * Update .drone.yml * Test * Update .drone.yml * Naming * Test upload * Update .drone.yml * Update .drone.yml * Update .drone.yml * Yolo * Yolo * Update .drone.yml * Update .drone.yml * Copy * Yolo * Release without bots * Update .drone.yml * Update .drone.yml * Test pipeline * Remove debug * Update .drone.yml * Filter pipeline stage * Update .drone.yml * Test * Bots release 22.0.5 (Test) * Release bot test #2 * Check if release * Update .drone.yml * Update .drone.yml * exit 78 * Update .drone.yml * Update .drone.yml * Add version checks * Update .drone.yml * Update .drone.yml * Test * Update build-release.bat * Update .drone.yml * Update .drone.yml * Update .drone.yml * Update build-release.bat * Update build-release.bat * Test pipeline * Update CHANGELOG.md * Bump * Update build-release.bat * Update build-release.bat * Shuffle * Take #45354 * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * F * Update windows-build.ps1 * Consolidate * Run it * Pop cache back in * Update linux-build.sh * Another release test * Update linux-build.sh * Update linux-build.sh * Update CMakeLists.txt * Trim windows assets * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * Update windows-build.ps1 * [22.1.0] Release * Crash reporting * Add version tag injection in the build pipeline * Update windows-build.ps1 * Full crash report on windows. * Update endpoint * [22.1.1] Release * [skip ci] update .drone.yml * Filter * Update .drone.yml * Update .drone.yml * Update .drone.yml * Update .drone.yml * Update .drone.yml * Update CHANGELOG.md Co-authored-by: KimLS <KimLS@peqtgc.com>
This commit is contained in:
+115
-5
@@ -3,13 +3,96 @@
|
||||
#include "crash.h"
|
||||
#include "strings.h"
|
||||
#include "process/process.h"
|
||||
#include "http/httplib.h"
|
||||
#include "http/uri.h"
|
||||
#include "json/json.h"
|
||||
#include "version.h"
|
||||
#include "eqemu_config.h"
|
||||
#include "serverinfo.h"
|
||||
#include "rulesys.h"
|
||||
#include "platform.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
#if WINDOWS
|
||||
#define popen _popen
|
||||
#endif
|
||||
|
||||
void SendCrashReport(const std::string &crash_report)
|
||||
{
|
||||
// can configure multiple endpoints if need be
|
||||
std::vector<std::string> endpoints = {
|
||||
"http://spire.akkadius.com/api/v1/analytics/server-crash-report",
|
||||
// "http://localhost:3010/api/v1/analytics/server-crash-report", // development
|
||||
};
|
||||
|
||||
auto config = EQEmuConfig::get();
|
||||
for (auto &e: endpoints) {
|
||||
uri u(e);
|
||||
|
||||
std::string base_url = fmt::format("{}://{}", u.get_scheme(), u.get_host());
|
||||
if (u.get_port()) {
|
||||
base_url += fmt::format(":{}", u.get_port());
|
||||
}
|
||||
|
||||
// client
|
||||
httplib::Client r(base_url);
|
||||
r.set_connection_timeout(1, 0);
|
||||
r.set_read_timeout(1, 0);
|
||||
r.set_write_timeout(1, 0);
|
||||
httplib::Headers headers = {
|
||||
{"Content-Type", "application/json"}
|
||||
};
|
||||
|
||||
// os info
|
||||
auto os = EQ::GetOS();
|
||||
auto cpus = EQ::GetCPUs();
|
||||
auto process_id = EQ::GetPID();
|
||||
auto rss = EQ::GetRSS() / 1048576.0;
|
||||
auto uptime = static_cast<uint32>(EQ::GetUptime());
|
||||
|
||||
// payload
|
||||
Json::Value p;
|
||||
p["platform_name"] = GetPlatformName();
|
||||
p["crash_report"] = crash_report;
|
||||
p["server_version"] = CURRENT_VERSION;
|
||||
p["compile_date"] = COMPILE_DATE;
|
||||
p["compile_time"] = COMPILE_TIME;
|
||||
p["server_name"] = config->LongName;
|
||||
p["server_short_name"] = config->ShortName;
|
||||
p["uptime"] = uptime;
|
||||
p["os_machine"] = os.machine;
|
||||
p["os_release"] = os.release;
|
||||
p["os_version"] = os.version;
|
||||
p["os_sysname"] = os.sysname;
|
||||
p["process_id"] = process_id;
|
||||
p["rss_memory"] = rss;
|
||||
p["cpus"] = cpus.size();
|
||||
p["origination_info"] = "";
|
||||
|
||||
if (!LogSys.origination_info.zone_short_name.empty()) {
|
||||
p["origination_info"] = fmt::format(
|
||||
"{} ({}) instance_id [{}]",
|
||||
LogSys.origination_info.zone_short_name,
|
||||
LogSys.origination_info.zone_long_name,
|
||||
LogSys.origination_info.instance_id
|
||||
);
|
||||
}
|
||||
|
||||
std::stringstream payload;
|
||||
payload << p;
|
||||
|
||||
if (auto res = r.Post(e, payload.str(), "application/json")) {
|
||||
if (res->status == 200) {
|
||||
LogInfo("Sent crash report");
|
||||
}
|
||||
else {
|
||||
LogError("Failed to send crash report to [{}]", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
|
||||
#include "StackWalker.h"
|
||||
@@ -21,22 +104,30 @@ public:
|
||||
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
|
||||
virtual void OnOutput(LPCSTR szText) {
|
||||
char buffer[4096];
|
||||
for(int i = 0; i < 4096; ++i) {
|
||||
if(szText[i] == 0) {
|
||||
for (int i = 0; i < 4096; ++i) {
|
||||
if (szText[i] == 0) {
|
||||
buffer[i] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if(szText[i] == '\n' || szText[i] == '\r') {
|
||||
if (szText[i] == '\n' || szText[i] == '\r') {
|
||||
buffer[i] = ' ';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
buffer[i] = szText[i];
|
||||
}
|
||||
}
|
||||
|
||||
std::string line = buffer;
|
||||
_lines.push_back(line);
|
||||
|
||||
Log(Logs::General, Logs::Crash, buffer);
|
||||
StackWalker::OnOutput(szText);
|
||||
}
|
||||
|
||||
const std::vector<std::string>& const GetLines() { return _lines; }
|
||||
private:
|
||||
std::vector<std::string> _lines;
|
||||
};
|
||||
|
||||
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
@@ -110,7 +201,20 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
|
||||
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
|
||||
EQEmuStackWalker sw;
|
||||
sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
|
||||
|
||||
if (RuleB(Analytics, CrashReporting)) {
|
||||
std::string crash_report;
|
||||
auto& lines = sw.GetLines();
|
||||
|
||||
for (auto& line : lines) {
|
||||
crash_report += line;
|
||||
crash_report += "\n";
|
||||
}
|
||||
|
||||
SendCrashReport(crash_report);
|
||||
}
|
||||
}
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
@@ -181,12 +285,18 @@ void print_trace()
|
||||
}
|
||||
|
||||
std::ifstream input(temp_output_file);
|
||||
std::string crash_report;
|
||||
for (std::string line; getline(input, line);) {
|
||||
LogCrash("{}", line);
|
||||
crash_report += fmt::format("{}\n", line);
|
||||
}
|
||||
|
||||
std::remove(temp_output_file.c_str());
|
||||
|
||||
if (RuleB(Analytics, CrashReporting)) {
|
||||
SendCrashReport(crash_report);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user