-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1571 from tgstation/MoreDebGotchas
.Deb Finalization
- Loading branch information
Showing
20 changed files
with
214 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
#!/usr/bin/make -f | ||
|
||
install: | ||
install -d $(DESTDIR)/opt/tgstation-server | ||
cp -r artifacts/* $(DESTDIR)/opt/tgstation-server | ||
install -d $(DESTDIR)/etc/tgstation-server | ||
cp artifacts/appsettings.yml $(DESTDIR)/etc/tgstation-server/appsettings.ex.yml | ||
echo -e "# tgstation-server configuration file\n# See /etc/tgstation-server/appsettings.ex.yml for details on individual configuration options" > $(DESTDIR)/etc/tgstation-server/appsettings.Production.yml | ||
dh_link $(DESTDIR)/etc/tgstation-server/appsettings.Production.yml $(DESTDIR)/opt/tgstation-server/appsettings.Production.yml | ||
install -d $(DESTDIR)/usr/bin | ||
install build/package/deb/tgs-configure $(DESTDIR)/usr/bin/ | ||
|
||
uninstall: | ||
mkdir -p $(DESTDIR)/opt/tgstation-server | ||
cp -r artifacts/* $(DESTDIR)/opt/tgstation-server/ | ||
build/package/deb/install_artifacts.sh "$(DESTDIR)" | ||
install -D build/package/deb/appsettings.Initial.yml "$(DESTDIR)/etc/tgstation-server/appsettings.Production.yml" | ||
install src/Tgstation.Server.Host/appsettings.yml "$(DESTDIR)/etc/tgstation-server/appsettings.ex.yml" | ||
install -D build/package/deb/tgs-configure "$(DESTDIR)/usr/bin/tgs-configure" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# tgstation-server configuration file | ||
# See /opt/tgstation-server/appsettings.yml for details on individual configuration options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/etc/tgstation-server/appsettings.Production.yml /opt/tgstation-server/appsettings.Production.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
#!/bin/sh -e | ||
|
||
if [[ "$1" = "configure" ]]; then | ||
systemctl mask tgstation-server | ||
fi | ||
|
||
#DEBHELPER# | ||
|
||
if [[ "$1" = "configure" ]]; then | ||
if [ "$1" = "configure" ]; then | ||
chmod 600 /etc/tgstation-server | ||
deb-systemd-helper stop 'tgstation-server.service' >/dev/null || true | ||
|
||
echo " _ _ _ _ " | ||
echo " | |_ __ _ ___| |_ __ _| |_(_) ___ _ __ ___ ___ _ ____ _____ _ __ " | ||
echo " | __/ _` / __| __/ _` | __| |/ _ \| '_ \ _____/ __|/ _ \ '__\ \ / / _ \ '__|" | ||
echo " | || (_| \__ \ || (_| | |_| | (_) | | | |_____\__ \ __/ | \ V / __/ | " | ||
echo " \__\__, |___/\__\__,_|\__|_|\___/|_| |_| |___/\___|_| \_/ \___|_| " | ||
echo " | __/ _\` / __| __/ _\` | __| |/ _ \\| '_ \\ _____/ __|/ _ \\ '__\\ \\ / / _ \\ '__|" | ||
echo " | || (_| \\__ \\ || (_| | |_| | (_) | | | |_____\\__ \\ __/ | \\ V / __/ | " | ||
echo " \\__\\__, |___/\\__\\__,_|\\__|_|\\___/|_| |_| |___/\\___|_| \\_/ \\___|_| " | ||
echo " |___/ " | ||
echo "tgstation-server is now installed but must first be configured" | ||
echo "Run 'sudo tgs-configure' to interactively configure your server" | ||
echo "Alternatively, edit '/etc/tgstation-server/appsettings.Production.yml' to your desired specifications" | ||
echo "Once complete, run 'sudo systemctl start tgstation-server' to start the service" | ||
echo "You should do this now to prevent the service from starting with invalid configuration on the next system reboot" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/sh -e | ||
|
||
cd artifacts && for f in $(find * -type f); do install -D "$f" "$1/opt/tgstation-server/$f"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/sh | ||
|
||
pushd /opt/tgstation-server | ||
dotnet /opt/tgstation-server/lib/Default/Tgstation.Server.Host.dll General:SetupWizardMode=Only | ||
popd | ||
cd /opt/tgstation-server | ||
export General__SetupWizardMode=Only | ||
exec /usr/bin/dotnet /opt/tgstation-server/lib/Default/Tgstation.Server.Host.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@echo off | ||
|
||
dotnet %~dp0Tgstation.Server.Host.Console.dll %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
#!/bin/sh -e | ||
|
||
script_full_path=$(dirname "$0") | ||
exec dotnet "$script_full_path/Tgstation.Server.Host.Console.dll" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
using Mono.Unix; | ||
using Mono.Unix.Native; | ||
|
||
namespace Tgstation.Server.Host.Watchdog | ||
{ | ||
/// <summary> | ||
/// Helper for checking POSIX signals. | ||
/// </summary> | ||
static class SignalChecker | ||
{ | ||
/// <summary> | ||
/// Forwards certain signals to a given <paramref name="childPid"/>. | ||
/// </summary> | ||
/// <param name="logger">The <see cref="ILogger"/> to write to.</param> | ||
/// <param name="childPid">The <see cref="System.Diagnostics.Process.Id"/> of the process to forward signals to.</param> | ||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param> | ||
/// <returns>A <see cref="Task"/> representing the running operation.</returns> | ||
public static async Task CheckSignals(ILogger logger, int childPid, CancellationToken cancellationToken) | ||
{ | ||
var signalTcs = new TaskCompletionSource<Signum>(); | ||
async Task<Signum?> CheckSignal(Signum signum) | ||
{ | ||
try | ||
{ | ||
using var unixSignal = new UnixSignal(signum); | ||
if (!unixSignal.IsSet) | ||
{ | ||
logger.LogTrace("Waiting for {signum}...", signum); | ||
while (!unixSignal.IsSet) | ||
await Task.Delay(TimeSpan.FromMilliseconds(250), cancellationToken); | ||
|
||
logger.LogTrace("{signum} received!", signum); | ||
} | ||
else | ||
logger.LogDebug("{signum} has already been sent", signum); | ||
|
||
signalTcs.TrySetResult(signum); | ||
} | ||
catch (OperationCanceledException) | ||
{ | ||
} | ||
|
||
return signum; | ||
} | ||
|
||
var tasks = new[] | ||
{ | ||
CheckSignal(Signum.SIGUSR1), | ||
CheckSignal(Signum.SIGUSR2), | ||
}; | ||
var completedTask = await Task.WhenAny(tasks); | ||
if (cancellationToken.IsCancellationRequested) | ||
{ | ||
await Task.WhenAll(tasks); | ||
return; | ||
} | ||
|
||
var signalReceived = await completedTask; | ||
logger.LogInformation("Received {signalReceived}, forwarding to main TGS process!", signalReceived); | ||
var result = Syscall.kill(childPid, signalReceived.Value); | ||
if (result != 0) | ||
logger.LogWarning( | ||
new UnixIOException(Stdlib.GetLastError()), | ||
"Failed to forward {signalReceived}!", | ||
signalReceived); | ||
|
||
// forward the other signal if necessary | ||
await Task.WhenAll(tasks); | ||
if (cancellationToken.IsCancellationRequested) | ||
return; | ||
|
||
var otherTask = tasks[0] == completedTask | ||
? tasks[1] | ||
: tasks[0]; | ||
|
||
signalReceived = await otherTask; | ||
logger.LogInformation("Received {signalReceived}, forwarding to main TGS process!", signalReceived); | ||
result = Syscall.kill(childPid, signalReceived.Value); | ||
if (result != 0) | ||
logger.LogWarning( | ||
new UnixIOException(Stdlib.GetLastError()), | ||
"Failed to forward {signalReceived}!", | ||
signalReceived); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.