Exemplo n.º 1
0
        private static async Task cleanSystem(CancellationToken cancellationToken = default)
        {
            var arenaDir = new DirectoryInfo("arena");

            arenaDir.Create();

            var logDir = arenaDir.CreateSubdirectory("tmp");

            logDir.Create();

            await OperationSystemService.RunCommandAsync(_cleanSystemCommand, new ProcessPayload(), logDir, null, log : false, cancellationToken : cancellationToken);
        }
Exemplo n.º 2
0
        public static async Task <ProcessPayload> RunServer(DirectoryInfo directory, CancellationToken cancellationToken = default)
        {
            var payload       = new ProcessPayload();
            var serverCommand = getCommandInfo(directory);
            var logDir        = directory.CreateSubdirectory("server-process-info");
            var unused        = Task.Run(async() => await OperationSystemService.RunCommandAsync(serverCommand, payload, logDir, directory.FullName, cancellationToken: cancellationToken), cancellationToken);

            while (!payload.IsRunning())
            {
                await Task.Delay(100, cancellationToken);
            }
            return(payload);
        }
Exemplo n.º 3
0
        public static async Task <ProcessPayload> RunClient(DirectoryInfo directory, int port, ClientMode mode, int clientTimeout = 1000, CancellationToken cancellationToken = default)
        {
            Debug.WriteLine($"running client file in directory {directory.FullName} in mode {mode}");

            var payload = new ProcessPayload();

            var serverCommand = getCommandInfo(directory, port, mode, clientTimeout);
            var logDir        = directory.CreateSubdirectory($"client-{mode}-process-info");
            var unused        = Task.Run(async() => await OperationSystemService.RunCommandAsync(
                                             serverCommand,
                                             payload,
                                             logDir,
                                             directory.FullName,
                                             cancellationToken: cancellationToken), cancellationToken);

            while (!payload.IsRunning())
            {
                await Task.Delay(100, cancellationToken);
            }

            Debug.WriteLine($"returning payload of client file in directory {directory.FullName} in mode {mode}");
            return(payload);
        }