diff --git a/Code/components/crash_handler/CrashHandler.cpp b/Code/components/crash_handler/CrashHandler.cpp index ad5f10041..7b43d12dc 100644 --- a/Code/components/crash_handler/CrashHandler.cpp +++ b/Code/components/crash_handler/CrashHandler.cpp @@ -5,17 +5,31 @@ #include -void InstallCrashHandler() +void InstallCrashHandler(bool aServer, bool aSkyrim) { sentry_options_t* options = sentry_options_new(); sentry_options_set_database_path(options, ".sentry-native"); -#if defined(TARGET_ST) - sentry_options_set_dsn(options, "https://96c601d451c94b32adb826aa62c6d50f@o228105.ingest.sentry.io/6269770"); -#else - sentry_options_set_dsn(options, "https://63886f8f9ef54328bc3373b07750a028@o228105.ingest.sentry.io/6273696"); -#endif + if (aSkyrim) + { + if (aServer) + sentry_options_set_dsn(options, + "https://6aff0a6955754bdebfffb064813b9042@o228105.ingest.sentry.io/6303666"); + else + sentry_options_set_dsn(options, + "https://96c601d451c94b32adb826aa62c6d50f@o228105.ingest.sentry.io/6269770"); + } + else + { + if (aServer) + sentry_options_set_dsn(options, + "https://2a3d561652734ca78e539c3fb5219a38@o228105.ingest.sentry.io/6303669"); + else + sentry_options_set_dsn(options, + "https://63886f8f9ef54328bc3373b07750a028@o228105.ingest.sentry.io/6273696"); + } + sentry_options_set_auto_session_tracking(options, false); sentry_options_set_symbolize_stacktraces(options, true); diff --git a/Code/components/crash_handler/CrashHandler.h b/Code/components/crash_handler/CrashHandler.h index 2765a47a0..67ae251d6 100644 --- a/Code/components/crash_handler/CrashHandler.h +++ b/Code/components/crash_handler/CrashHandler.h @@ -1,4 +1,4 @@ #pragma once -void InstallCrashHandler(); +void InstallCrashHandler(bool aServer = false, bool aSkyrim = true); void UninstallCrashHandler(); diff --git a/Code/server/main.cpp b/Code/server/main.cpp index 0f30f13e7..f4f70e0eb 100644 --- a/Code/server/main.cpp +++ b/Code/server/main.cpp @@ -20,6 +20,8 @@ #include #include +#include + constexpr char kSettingsFileName[] = #if SKYRIM "STServer.ini" @@ -272,9 +274,14 @@ static bool IsEULAAccepted() int main(int argc, char** argv) { + InstallCrashHandler(true); + LogInstance logInstance; (void)logInstance; + int* i = 0; + *i = 42; + if (!IsEULAAccepted()) { spdlog::error("Please accept the EULA by setting bConfirmEULA to true in EULA.txt"); @@ -291,5 +298,7 @@ int main(int argc, char** argv) } cpRunner->RunGSThread(); + UninstallCrashHandler(); + return 0; } diff --git a/Code/server/xmake.lua b/Code/server/xmake.lua index d7198dc31..9b7dff450 100644 --- a/Code/server/xmake.lua +++ b/Code/server/xmake.lua @@ -1,7 +1,19 @@ +local function istable(t) return type(t) == 'table' end + local function build_server() add_includedirs( ".", "../../Libraries/") + + after_install(function(target) + local linkdir = target:pkg("sentry-native"):get("linkdirs") + if istable(linkdir) then + linkdir = linkdir[1] -- Yes lua index starts at 1 + end + local bindir = path.join(linkdir, "..", "bin") + os.cp(bindir, target:installdir()) + end) + set_pcxxheader("stdafx.h") add_headerfiles("**.h") add_files( @@ -13,6 +25,7 @@ local function build_server() "CommonLib", "Console", "ESLoader", + "CrashHandler", "BaseLib", "AdminProtocol", "TiltedScript", @@ -28,7 +41,8 @@ local function build_server() "glm", "entt", "cpp-httplib", - "tiltedcore") + "tiltedcore", + "sentry-native") end target("SkyrimTogetherServer") diff --git a/Dockerfile b/Dockerfile index 0d6f8737b..c5fe5d0de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,12 @@ RUN export XMAKE_ROOTDIR="/root/.local/bin" && \ export PATH="$XMAKE_ROOTDIR:$PATH" && \ export XMAKE_ROOT=y && \ xmake config -y && \ -xmake -j8 +xmake -j8 && \ +objcopy --only-keep-debug /home/server/build/linux/x64/release/SkyrimTogetherServer /home/server/build/linux/x64/release/SkyrimTogetherServer.debug +RUN export XMAKE_ROOTDIR="/root/.local/bin" && \ +export PATH="$XMAKE_ROOTDIR:$PATH" && \ +export XMAKE_ROOT=y && \ +xmake install -o package FROM ubuntu:20.04 AS skyrim @@ -35,7 +40,9 @@ RUN apt update && \ apt remove software-properties-common -y && \ apt autoremove -y -COPY --from=builder /home/server/build/linux/x64/release/SkyrimTogetherServer /home/server/SkyrimTogetherServer +COPY --from=builder /home/server/package/bin/SkyrimTogetherServer /home/server/SkyrimTogetherServer +COPY --from=builder /home/server/package/bin/crashpad_handler /home/server/crashpad_handler +COPY --from=builder /home/server/build/linux/x64/release/SkyrimTogetherServer.debug /home/server/SkyrimTogetherServer.debug WORKDIR /home/server ENTRYPOINT ["./SkyrimTogetherServer"] diff --git a/MakeLinux.cmd b/MakeLinux.cmd new file mode 100644 index 000000000..67e852620 --- /dev/null +++ b/MakeLinux.cmd @@ -0,0 +1,6 @@ +@echo off + +docker build . -t skyrim_build +docker run --rm --entrypoint /bin/sh skyrim_build -c "cat /home/server/SkyrimTogetherServer.debug" > ./build/linux/x64/SkyrimTogetherServer.debug +docker run --rm --entrypoint /bin/sh skyrim_build -c "cat /home/server/SkyrimTogetherServer" > ./build/linux/x64/SkyrimTogetherServer +timeout /t 30 /nobreak \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 025e84729..94d6dd1f1 100644 --- a/xmake.lua +++ b/xmake.lua @@ -56,6 +56,7 @@ task("upload-symbols") import("core.base.option") local key = option.get('key') + local linux = option.get('linux') if key ~= nil then import("net.http") @@ -64,13 +65,26 @@ task("upload-symbols") config.load() local sentrybin = path.join(os.projectdir(), "build", "sentry-cli.exe") - local path = path.join(os.projectdir(), "build", config.get("plat"), config.get("arch"), config.get("mode"), "SkyrimTogether.pdb") + local file_path = path.join(os.projectdir(), "build", config.get("plat"), config.get("arch"), config.get("mode"), "SkyrimTogether.pdb") + if linux then + file_path = path.join(os.projectdir(), "build", "linux", "x64", "SkyrimTogetherServer.debug") + end if not os.exists(sentrybin) then http.download("https://github.com/getsentry/sentry-cli/releases/download/2.0.2/sentry-cli-Windows-x86_64.exe", sentrybin) end - os.execv(sentrybin, {"--auth-token", key, "upload-dif", "-o", "together-team", "-p", "st-reborn", path}) + local project = "st-reborn" + if linux then + project = "st-server" + end + + os.execv(sentrybin, {"--auth-token", key, "upload-dif", "-o", "together-team", "-p", project, file_path}) + + if not linux then + local file_path = path.join(os.projectdir(), "build", config.get("plat"), config.get("arch"), config.get("mode"), "SkyrimTogetherServer.pdb") + os.execv(sentrybin, {"--auth-token", key, "upload-dif", "-o", "together-team", "-p", "st-server", file_path}) + end else print("An API key is required to proceed!") @@ -81,6 +95,7 @@ task("upload-symbols") usage = "xmake upload-symbols", description = "Upload symbols to sentry", options = { - {'k', "key", "kv", nil, "The API key to use." } + {'k', "key", "kv", nil, "The API key to use." }, + {'l', "linux", "v", false, "Upload linux symbols that were manually copied." }, } } \ No newline at end of file