Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 7ed030a

Browse files
committed
Use constants in KesterlServerOptionsSystemdExtensions
1 parent b9f0343 commit 7ed030a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Microsoft.AspNetCore.Server.Kestrel/Systemd/KesterlServerOptionsSystemdExtensions.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ namespace Microsoft.AspNetCore.Hosting
1010
{
1111
public static class KesterlServerOptionsSystemdExtensions
1212
{
13+
// SD_LISTEN_FDS_START https://www.freedesktop.org/software/systemd/man/sd_listen_fds.html
14+
private const ulong SdListenFdsStart = 3;
15+
private const string ListenPidEnvVar = "LISTEN_PID";
16+
1317
/// <summary>
1418
/// Open file descriptor (SD_LISTEN_FDS_START) initialized by systemd socket-based activation logic if available.
1519
/// </summary>
@@ -30,10 +34,9 @@ public static KestrelServerOptions UseSystemd(this KestrelServerOptions options)
3034
/// </returns>
3135
public static KestrelServerOptions UseSystemd(this KestrelServerOptions options, Action<ListenOptions> configure)
3236
{
33-
if (string.Equals(Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture), Environment.GetEnvironmentVariable("LISTEN_PID"), StringComparison.Ordinal))
37+
if (string.Equals(Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture), Environment.GetEnvironmentVariable(ListenPidEnvVar), StringComparison.Ordinal))
3438
{
35-
// SD_LISTEN_FDS_START = 3
36-
options.ListenHandle(3, configure);
39+
options.ListenHandle(SdListenFdsStart, configure);
3740
}
3841

3942
return options;

0 commit comments

Comments
 (0)