From 9486bde26cbb3afd841889ab5ab4ee4201d0c132 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sun, 15 May 2022 21:48:23 -0400 Subject: [PATCH] Add systemd units, build & start production scripts to repo --- .../.idea.ProjectLighthouse/.idea/indexLayout.xml | 1 + scripts-and-tools/build.sh | 14 ++++++++++++++ .../create-migration.sh | 0 scripts-and-tools/project-lighthouse-api.service | 13 +++++++++++++ .../project-lighthouse-gameserver.service | 13 +++++++++++++ .../project-lighthouse-website.service | 13 +++++++++++++ scripts-and-tools/start.sh | 13 +++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 scripts-and-tools/build.sh rename create-migration.sh => scripts-and-tools/create-migration.sh (100%) create mode 100644 scripts-and-tools/project-lighthouse-api.service create mode 100644 scripts-and-tools/project-lighthouse-gameserver.service create mode 100644 scripts-and-tools/project-lighthouse-website.service create mode 100644 scripts-and-tools/start.sh diff --git a/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml b/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml index 022ac2e7..46037895 100644 --- a/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml +++ b/.idea/.idea.ProjectLighthouse/.idea/indexLayout.xml @@ -14,6 +14,7 @@ create-migration.sh docker-compose.yml global.json + scripts-and-tools .idea/.idea.ProjectLighthouse/.idea/workspace.xml diff --git a/scripts-and-tools/build.sh b/scripts-and-tools/build.sh new file mode 100644 index 00000000..8be9cefb --- /dev/null +++ b/scripts-and-tools/build.sh @@ -0,0 +1,14 @@ +# Build script for production +# +# No arguments +# Called manually + +cd project-lighthouse || (echo "Source directory not found, pls clone properly~" && exit 1) + +echo "Pulling latest changes..." +git pull + +echo "Building..." +dotnet build -c Release + +exit $? # Expose error code from build command \ No newline at end of file diff --git a/create-migration.sh b/scripts-and-tools/create-migration.sh similarity index 100% rename from create-migration.sh rename to scripts-and-tools/create-migration.sh diff --git a/scripts-and-tools/project-lighthouse-api.service b/scripts-and-tools/project-lighthouse-api.service new file mode 100644 index 00000000..b2b73a49 --- /dev/null +++ b/scripts-and-tools/project-lighthouse-api.service @@ -0,0 +1,13 @@ +[Unit] +Description=Project Lighthouse API - a clean-room, open-source custom server for LBP +Documentation=https://github.com/LBPUnion/ProjectLighthouse + +[Service] +Type=simple +ExecStart=/srv/lighthouse/start.sh API +TimeoutStopSec=15 +User=lighthouse + +[Install] +Alias=lighthouse-api +WantedBy=multi-user.target \ No newline at end of file diff --git a/scripts-and-tools/project-lighthouse-gameserver.service b/scripts-and-tools/project-lighthouse-gameserver.service new file mode 100644 index 00000000..8729c991 --- /dev/null +++ b/scripts-and-tools/project-lighthouse-gameserver.service @@ -0,0 +1,13 @@ +[Unit] +Description=Project Lighthouse GameServer - a clean-room, open-source custom server for LBP +Documentation=https://github.com/LBPUnion/ProjectLighthouse + +[Service] +Type=simple +ExecStart=/srv/lighthouse/start.sh GameServer +TimeoutStopSec=15 +User=lighthouse + +[Install] +Alias=lighthouse-website +WantedBy=multi-user.target \ No newline at end of file diff --git a/scripts-and-tools/project-lighthouse-website.service b/scripts-and-tools/project-lighthouse-website.service new file mode 100644 index 00000000..d2c5d5c1 --- /dev/null +++ b/scripts-and-tools/project-lighthouse-website.service @@ -0,0 +1,13 @@ +[Unit] +Description=Project Lighthouse Website - a clean-room, open-source custom server for LBP +Documentation=https://github.com/LBPUnion/ProjectLighthouse + +[Service] +Type=simple +ExecStart=/srv/lighthouse/start.sh Website +TimeoutStopSec=15 +User=lighthouse + +[Install] +Alias=lighthouse-website +WantedBy=multi-user.target \ No newline at end of file diff --git a/scripts-and-tools/start.sh b/scripts-and-tools/start.sh new file mode 100644 index 00000000..10d2803a --- /dev/null +++ b/scripts-and-tools/start.sh @@ -0,0 +1,13 @@ +# Startup script for production +# +# $1: Server to start; case sensitive!!!!! +# Called from systemd units + +cd "$HOME"/data || (echo "Data directory not found, pls create one~" && exit 1) + +echo "Running..." + +# Normally this requires ASPNETCORE_URLS but we override that in the configuration +dotnet ../project-lighthouse/ProjectLighthouse.Servers."$1"/bin/Release/net6.0/LBPUnion.ProjectLighthouse.Servers."$1".dll + +exit $? # Expose error code from dotnet command \ No newline at end of file