forked from projectkudu/kudu
-
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.
Linux - Support for container restart trigger (projectkudu#2529)
Linux - Support for container restart trigger Linux App Service now supports a generic file-based communication mechanism for requesting a restart of the app container. This was previously implemented in a limited fashion only for the "Docker CI" webhook. This generalizes the implementation and also requests a restart after a git deployment by default, in addition to receipt of a Docker webhook request.
- Loading branch information
1 parent
0cd9814
commit 7429a14
Showing
9 changed files
with
103 additions
and
15 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
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,42 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.IO; | ||
using Kudu.Core.Helpers; | ||
|
||
namespace Kudu.Core.Infrastructure | ||
{ | ||
// Utility for touching the restart trigger file on Linux, which will restart the | ||
// site container. | ||
// Contents of the trigger file are irrelevant but this leaves a small explanation for | ||
// users who stumble on it. | ||
public static class LinuxContainerRestartTrigger | ||
{ | ||
private const string CONFIG_DIR_NAME = "config"; | ||
private const string TRIGGER_FILENAME = "restartTrigger.txt"; | ||
|
||
private static readonly string FILE_CONTENTS_FORMAT = String.Concat( | ||
"Modifying this file will trigger a restart of the app container.", | ||
System.Environment.NewLine, System.Environment.NewLine, | ||
"The last modification Kudu made to this file was at {0}, for the following reason: {1}.", | ||
System.Environment.NewLine); | ||
|
||
public static void RequestContainerRestart(IEnvironment environment, string reason) | ||
{ | ||
if (OSDetector.IsOnWindows()) | ||
{ | ||
throw new NotSupportedException("RequestContainerRestart not supported on Windows"); | ||
} | ||
|
||
var restartTriggerPath = Path.Combine(environment.SiteRootPath, CONFIG_DIR_NAME, TRIGGER_FILENAME); | ||
|
||
FileSystemHelpers.CreateDirectory(Path.GetDirectoryName(restartTriggerPath)); | ||
|
||
var fileContents = String.Format( | ||
FILE_CONTENTS_FORMAT, | ||
DateTimeOffset.UtcNow.ToString("o", CultureInfo.InvariantCulture), | ||
reason); | ||
|
||
FileSystemHelpers.WriteAllText(restartTriggerPath, fileContents); | ||
} | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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