public static void Main(string[] args) { ScalarPlatformLoader.Initialize(); using (JsonTracer tracer = new JsonTracer("Microsoft.Git.GVFS.Service.UI", "Service.UI")) { string error; string serviceUILogDirectory = ScalarPlatform.Instance.GetLogsDirectoryForGVFSComponent(ScalarConstants.Service.UIName); if (!ScalarPlatform.Instance.FileSystem.TryCreateDirectoryWithAdminAndUserModifyPermissions(serviceUILogDirectory, out error)) { EventMetadata metadata = new EventMetadata(); metadata.Add(nameof(serviceUILogDirectory), serviceUILogDirectory); metadata.Add(nameof(error), error); tracer.RelatedWarning( metadata, "Failed to create service UI logs directory", Keywords.Telemetry); } else { string logFilePath = ScalarEnlistment.GetNewScalarLogFileName( serviceUILogDirectory, ScalarConstants.LogFileTypes.ServiceUI, logId: Environment.UserName); tracer.AddLogFileEventListener(logFilePath, EventLevel.Informational, Keywords.Any); } WinToastNotifier winToastNotifier = new WinToastNotifier(tracer); ScalarToastRequestHandler toastRequestHandler = new ScalarToastRequestHandler(winToastNotifier, tracer); GVFSServiceUI process = new GVFSServiceUI(tracer, toastRequestHandler); process.Start(args); } }
public static void Main(string[] args) { ScalarPlatformLoader.Initialize(); using (JsonTracer tracer = new JsonTracer(ScalarConstants.Service.ServiceName, ScalarConstants.Service.ServiceName)) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { AppDomain.CurrentDomain.UnhandledException += EventLogUnhandledExceptionHandler; using (WindowsScalarService service = new WindowsScalarService(tracer)) { // This will fail with a popup from a command prompt. To install as a service, run: // %windir%\Microsoft.NET\Framework64\v4.0.30319\installutil Scalar.Service.exe ServiceBase.Run(service); } } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { AppDomain.CurrentDomain.UnhandledException += JsonUnhandledExceptionHandler; CreateMacService(tracer, args).Run(); } else { throw new NotImplementedException(); } } }
public static void Main(string[] args) { ScalarPlatformLoader.Initialize(); Parser.Default.ParseArguments <UpgradeOptions>(args) .WithParsed(options => UpgradeOrchestratorFactory.Create(options).Execute()); }
public static void Main(string[] args) { ScalarPlatformLoader.Initialize(); Type[] verbTypes = new Type[] { typeof(CacheServerVerb), typeof(CloneVerb), typeof(ConfigVerb), typeof(DeleteVerb), typeof(DiagnoseVerb), typeof(ListVerb), typeof(PauseVerb), typeof(RegisterVerb), typeof(ResumeVerb), typeof(RunVerb), typeof(UnregisterVerb), typeof(UpgradeVerb), }; int consoleWidth = 80; // Running in a headless environment can result in a Console with a // WindowWidth of 0, which causes issues with CommandLineParser try { if (Console.WindowWidth > 0) { consoleWidth = Console.WindowWidth; } } catch (IOException) { } try { new Parser( settings => { settings.CaseSensitive = false; settings.EnableDashDash = true; settings.IgnoreUnknownArguments = false; settings.HelpWriter = Console.Error; settings.MaximumDisplayWidth = consoleWidth; }) .ParseArguments(args, verbTypes) .WithNotParsed( errors => { if (errors.Any(error => error is TokenError)) { Environment.Exit((int)ReturnCode.ParsingError); } }) .WithParsed <CloneVerb>( clone => { // We handle the clone verb differently, because clone cares if the enlistment path // was not specified vs if it was specified to be the current directory clone.Execute(); Environment.Exit((int)ReturnCode.Success); }) .WithParsed <ScalarVerb.ForNoEnlistment>( verb => { verb.Execute(); Environment.Exit((int)ReturnCode.Success); }) .WithParsed <ScalarVerb>( verb => { // For all other verbs, they don't care if the enlistment root is explicitly // specified or implied to be the current directory if (string.IsNullOrEmpty(verb.EnlistmentRootPathParameter)) { verb.EnlistmentRootPathParameter = Environment.CurrentDirectory; } verb.Execute(); Environment.Exit((int)ReturnCode.Success); }); } catch (ScalarVerb.VerbAbortedException e) { // Calling Environment.Exit() is required, to force all background threads to exit as well Environment.Exit((int)e.Verb.ReturnCode); } }