/// <nodoc/> #pragma warning disable IDE1006 // Naming Styles (ignore missing 'async' in the method name) public static async Task <int> Main(string[] args) #pragma warning restore IDE1006 // Naming Styles { try { Console.WriteLine($"{nameof(MaterializationDaemon)} started at {DateTime.UtcNow}"); Console.WriteLine($"{MaterializationDaemon.MaterializationDaemonLogPrefix}Command line arguments: "); Console.WriteLine($"{MaterializationDaemon.MaterializationDaemonLogPrefix}{string.Join($"{Environment.NewLine}{MaterializationDaemon.MaterializationDaemonLogPrefix}", args)}"); Console.WriteLine(); MaterializationDaemon.EnsureCommandsInitialized(); var confCommand = ServicePipDaemon.ServicePipDaemon.ParseArgs(args, new UnixParser()); if (confCommand.Command.NeedsIpcClient) { using (var rpc = CreateClient(confCommand)) { var result = confCommand.Command.ClientAction(confCommand, rpc); rpc.RequestStop(); await rpc.Completion; return(result); } } else { return(confCommand.Command.ClientAction(confCommand, null)); } } catch (ArgumentException e) { Error(e.Message); return(3); } }
private static async Task <IIpcResult> RegisterManifestInternalAsync(ConfiguredCommand conf, MaterializationDaemon daemon) { var directoryPaths = Directory.GetValues(conf.Config).ToArray(); var directoryIds = DirectoryId.GetValues(conf.Config).ToArray(); if (directoryPaths.Length != directoryIds.Length) { return(new IpcResult( IpcResultStatus.GenericError, I($"Directory counts don't match: #directories = {directoryPaths.Length}, #directoryIds = {directoryIds.Length}"))); } if (daemon.ApiClient == null) { return(new IpcResult(IpcResultStatus.GenericError, "ApiClient is not initialized")); } var manifests = new List <SealedDirectoryFile>(); for (int i = 0; i < directoryIds.Length; i++) { var directoryArtifact = BuildXL.Ipc.ExternalApi.DirectoryId.Parse(directoryIds[i]); var possibleContent = await daemon.ApiClient.GetSealedDirectoryContent(directoryArtifact, directoryPaths[i]); if (!possibleContent.Succeeded) { return(new IpcResult( IpcResultStatus.GenericError, I($"Failed to get the content of a directory artifact ({directoryIds[i]}, {directoryPaths[i]}){Environment.NewLine}{possibleContent.Failure.DescribeIncludingInnerFailures()}"))); } manifests.AddRange(possibleContent.Result); } daemon.Logger.Verbose(string.Join(Environment.NewLine, manifests.Select(f => f.FileName))); // TODO: placeholder for now - to be implemented in another pr return(IpcResult.Success("done")); }