Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SystemdHelpers.cs #94191

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ namespace Microsoft.Extensions.Hosting.Systemd
/// <summary>
/// Helper methods for systemd Services.
/// </summary>
public static partial class SystemdHelpers
public static class SystemdHelpers
{
private static bool? _isSystemdService;
private static readonly bool _isSystemdService = GetIsSystemdService();

/// <summary>
/// Check if the current process is hosted as a systemd Service.
/// </summary>
/// <returns>
/// <see langword="true" /> if the current process is hosted as a systemd Service; otherwise, <see langword="false" />.
/// </returns>
public static bool IsSystemdService()
=> _isSystemdService ??= GetIsSystemdService();
public static bool IsSystemdService() => _isSystemdService;

private static bool GetIsSystemdService()
{
Expand Down