Skip to content

Commit

Permalink
timeout set
Browse files Browse the repository at this point in the history
  • Loading branch information
shukriadams committed May 1, 2024
1 parent 0c4f81a commit 7824851
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Tetrifact.Core/ArchiveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void Archive7Zip(string packageId, string archivePathTemp)
long cacheUpdateIncrements = manifest.Files.Count / 100;
long counter = 0;

manifest.Files.AsParallel().ForAll(delegate (ManifestItem file)
manifest.Files.AsParallel().WithDegreeOfParallelism(_settings.ArchiveCPUThreads).ForAll(delegate (ManifestItem file)
{
string targetPath = Path.Join(tempDir1, file.Path);
List<string> knownDirectories = new List<string>();
Expand Down Expand Up @@ -263,7 +263,7 @@ private void Archive7Zip(string packageId, string archivePathTemp)
// -aoa swtich forces overwriting of existing zip file should it exist
string command = $"{_settings.SevenZipBinaryPath} -aoa a -tzip -mx={_settings.ArchiveCPUThreads} -mmt=on {archivePathTemp} {tempDir2}/*";

ShellResult result = Shell.Run(command);
ShellResult result = Shell.Run(command, false, 3600000); // set timeout to 1 hour
TimeSpan compressTaken = DateTime.Now - compressStart;
if (result.ExitCode == 0)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Tetrifact.Core/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public class Shell
/// Runs a shell command SYNCHRONOUSLY, returns a tuple with exit code, stdout and stderr.
/// </summary>
/// <param name="command"></param>
/// <param name="timeout">milliseconds to timeout</param>
/// <returns></returns>
public static ShellResult Run(string command, bool verbose=false)
public static ShellResult Run(string command, bool verbose=false, int timeout= 50000)
{
Process cmd = new Process();

Expand All @@ -49,8 +50,6 @@ public static ShellResult Run(string command, bool verbose=false)
cmd.StartInfo.UseShellExecute = false;
List<string> stdOut = new List<string>();
List<string> stdErr = new List<string>();
int timeout = 50000;


//cmd.Start();

Expand Down Expand Up @@ -91,7 +90,6 @@ public static ShellResult Run(string command, bool verbose=false)
cmd.StandardInput.Flush();
cmd.StandardInput.Close();


while (!cmd.StandardOutput.EndOfStream)
{
string line = cmd.StandardOutput.ReadLine();
Expand Down

0 comments on commit 7824851

Please sign in to comment.