コード例 #1
0
 public DeploymentController(ITracer tracer,
                             IEnvironment environment,
                             IAnalytics analytics,
                             IDeploymentManager deploymentManager,
                             IDeploymentStatusManager status,
                             IDeploymentSettingsManager settings,
                             //IOperationLock deploymentLock,
                             IDictionary <string, IOperationLock> namedLocks,
                             IRepositoryFactory repositoryFactory)
 {
     _tracer            = tracer;
     _environment       = environment;
     _analytics         = analytics;
     _deploymentManager = deploymentManager;
     _status            = status;
     _settings          = settings;
     _deploymentLock    = (AllSafeLinuxLock)namedLocks["deployment"];
     _repositoryFactory = repositoryFactory;
 }
コード例 #2
0
ファイル: ScanManager.cs プロジェクト: Hazhzeng/KuduLite
        public async Task <bool> PerformBackgroundScan(ITracer _tracer, AllSafeLinuxLock _scanLock, String folderPath, CancellationToken token, String scanId, String mainScanDirPath)
        {
            var successfulScan = true;

            await Task.Run(() =>
            {
                _scanLock.LockOperation(() =>
                {
                    _scanLock.SetLockMsg(Resources.ScanUnderwayMsg);

                    String statusFilePath = Path.Combine(folderPath, Constants.ScanStatusFile);


                    String logFilePath = Path.Combine(folderPath, Constants.ScanLogFile);
                    _tracer.Trace("Starting Scan {0}, ScanCommand: {1}, LogFile: {2}", scanId, Constants.ScanCommand, logFilePath);

                    UpdateScanStatus(folderPath, ScanStatus.Executing, null);

                    var escapedArgs           = Constants.ScanCommand + " " + logFilePath;
                    Process _executingProcess = new Process()
                    {
                        StartInfo = new ProcessStartInfo
                        {
                            FileName  = "/bin/bash",
                            Arguments = "-c \"" + escapedArgs + "\"",
                            RedirectStandardOutput = true,
                            UseShellExecute        = false,
                            CreateNoWindow         = true,
                        }
                    };
                    _executingProcess.Start();

                    string tempScanFilePath = GetTempScanFilePath(mainScanDirPath);
                    //Check if process is completing before timeout
                    while (!_executingProcess.HasExited)
                    {
                        //Process still running, but timeout is done
                        //Or Process is still running but scan has been stopped by user
                        if (token.IsCancellationRequested || (tempScanFilePath != null && !FileSystemHelpers.FileExists(tempScanFilePath)))
                        {
                            //Kill process
                            _executingProcess.Kill(true, _tracer);
                            //Wait for process to be completely killed
                            _executingProcess.WaitForExit();
                            successfulScan = false;
                            if (token.IsCancellationRequested)
                            {
                                _tracer.Trace("Scan {0} has timed out at {1}", scanId, DateTime.UtcNow.ToString("yyy-MM-dd_HH-mm-ssZ"));

                                //Update status file
                                UpdateScanStatus(folderPath, ScanStatus.TimeoutFailure, null);
                            }
                            else
                            {
                                _tracer.Trace("Scan {0} has been force stopped at {1}", scanId, DateTime.UtcNow.ToString("yyy-MM-dd_HH-mm-ssZ"));

                                //Update status file
                                UpdateScanStatus(folderPath, ScanStatus.ForceStopped, null);
                            }

                            break;
                        }
                    }

                    //Clean up the temp file
                    StopScan(mainScanDirPath);

                    //Update status file with success
                    if (successfulScan)
                    {
                        //Check if process terminated with errors
                        if (_executingProcess.ExitCode != 0)
                        {
                            UpdateScanStatus(folderPath, ScanStatus.Failed, null);
                            _tracer.Trace("Scan {0} has terminated with exit code {1}. More info found in {2}", scanId, _executingProcess.ExitCode, logFilePath);
                        }
                        else
                        {
                            UpdateScanStatus(folderPath, ScanStatus.Success, null);
                            _tracer.Trace("Scan {0} is Successful", scanId);
                        }
                    }
                }, "Performing continuous scan", TimeSpan.Zero);

                _scanLock.SetLockMsg("");
            });

            return(successfulScan);
        }
コード例 #3
0
ファイル: ScanManager.cs プロジェクト: Hazhzeng/KuduLite
        // private string tempScanFilePath = null;

        public ScanManager(ITracer tracer, IDictionary <string, IOperationLock> namedLocks)
        {
            _tracer   = tracer;
            _scanLock = (AllSafeLinuxLock)namedLocks["deployment"];
        }