This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2 from corenting/update_net_5_0
Update to .NET 5.0
- Loading branch information
Showing
6 changed files
with
63 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
RUNTIME_IDENTIFIER?=linux-x64 | ||
BUILD_FOLDER=src/MumbleServerStatsd/bin/Release/netcoreapp3.1/$(RUNTIME_IDENTIFIER)/publish | ||
VERSION=$(shell git rev-parse --short HEAD) | ||
BUILD_FOLDER=src/MumbleServerStatsd/bin/Release/net5.0/$(RUNTIME_IDENTIFIER)/publish | ||
|
||
.PHONY: release | ||
release: | ||
dotnet publish src/MumbleServerStatsd -p:PublishTrimmed=true -r $(RUNTIME_IDENTIFIER) -c Release /p:PublishSingleFile=true | ||
rm src/MumbleServerStatsd/bin/Release/netcoreapp3.1/$(RUNTIME_IDENTIFIER)/publish/MumbleServerStatsd.pdb | ||
dotnet publish src/MumbleServerStatsd -r $(RUNTIME_IDENTIFIER) -c Release /p:PublishTrimmed=true /p:PublishSingleFile=true /p:IncludeNativeLibrariesInSingleFile=true | ||
rm src/MumbleServerStatsd/bin/Release/net5.0/$(RUNTIME_IDENTIFIER)/publish/MumbleServerStatsd.pdb | ||
mkdir -p build | ||
zip -r -j build/mumble_server_statsd_$(VERSION)_$(RUNTIME_IDENTIFIER).zip $(BUILD_FOLDER)/MumbleServerStatsd* | ||
zip -r -j build/mumble_server_statsd_$(RUNTIME_IDENTIFIER).zip $(BUILD_FOLDER)/MumbleServerStatsd* | ||
|
||
.PHONY: release-all | ||
release-all: | ||
RUNTIME_IDENTIFIER=linux-x64 make release | ||
RUNTIME_IDENTIFIER=linux-musl-x64 make release | ||
RUNTIME_IDENTIFIER=linux-arm make release | ||
RUNTIME_IDENTIFIER=linux-arm64 make release | ||
RUNTIME_IDENTIFIER=win-x64 make release | ||
RUNTIME_IDENTIFIER=win-arm64 make release | ||
|
||
.PHONY: clean | ||
clean: | ||
dotnet clean | ||
rm -rf build | ||
rm -rf build |
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 was deleted.
Oops, something went wrong.
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,30 +1,49 @@ | ||
namespace MumbleServerStatsd | ||
{ | ||
using System; | ||
using CommandLine; | ||
using CommandLine.Text; | ||
using MumbleServerStatsd.Ping; | ||
|
||
/// <summary> | ||
/// CLI Entrypoint. | ||
/// </summary> | ||
public class Program | ||
{ | ||
/// <summary> | ||
/// statsd client for mumble-server. | ||
/// </summary> | ||
/// <param name="mumbleHostname">hostname or IP of the mumble server.</param> | ||
/// <param name="statsdHostname">hostname or IP of the statsd server.</param> | ||
/// <param name="statsdPort">port of the statsd server (optional, 8125 if not set).</param> | ||
/// <param name="mumblePort">port of the server (optional, 64738 if not set).</param> | ||
public static void Main(string mumbleHostname, string statsdHostname, int statsdPort = 8125, int mumblePort = 64738) | ||
public class Options | ||
{ | ||
if (mumbleHostname == null) | ||
[Option("mumble-hostname", Required = true, HelpText = "Hostname or IP of the mumble server.")] | ||
public string MumbleHostname { get; set; } | ||
|
||
[Option("statsd-hostname", Required = true, HelpText = "Hostname or IP of the statsd server.")] | ||
public string StatsdHostname { get; set; } | ||
|
||
[Option("statsd-port", Default = 8125, HelpText = "Port of the statsd server (optional, 8125 if not set).")] | ||
public int StatsdPort { get; set; } | ||
|
||
[Option("mumble-port", Default = 64738, HelpText = "Port of the mumble server (optional, 64738 if not set).")] | ||
public int MumblePort { get; set; } | ||
} | ||
|
||
public static void Main(string[] args) | ||
{ | ||
var parser = new CommandLine.Parser(with => with.HelpWriter = null); | ||
var parserResult = parser.ParseArguments<Options>(args); | ||
var helpText = HelpText.AutoBuild(parserResult, h => | ||
{ | ||
Console.Error.WriteLine("Error: you need to specify an hostname (see --help for help)."); | ||
Environment.Exit(1); | ||
} | ||
h.AdditionalNewLineAfterOption = false; | ||
h.Copyright = ""; | ||
return h; | ||
}, e => e); | ||
|
||
PingResponse ping = PingUtils.PingServer(mumbleHostname, mumblePort); | ||
Statsd.SendGauge(statsdHostname, statsdPort, ping.ConnectedUsers); | ||
parserResult | ||
.WithParsed<Options>(options => { | ||
PingResponse ping = PingUtils.PingServer(options.MumbleHostname, options.MumblePort); | ||
Statsd.SendGauge(options.StatsdHostname, options.StatsdPort, ping.ConnectedUsers); | ||
}) | ||
.WithNotParsed(errs => { | ||
Console.Error.WriteLine(helpText); | ||
}); | ||
} | ||
} | ||
} |