ApplicationHost.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. using MediaBrowser.Api;
  2. using MediaBrowser.Common;
  3. using MediaBrowser.Common.Configuration;
  4. using MediaBrowser.Common.Constants;
  5. using MediaBrowser.Common.Extensions;
  6. using MediaBrowser.Common.Implementations;
  7. using MediaBrowser.Common.Implementations.ScheduledTasks;
  8. using MediaBrowser.Common.IO;
  9. using MediaBrowser.Common.MediaInfo;
  10. using MediaBrowser.Common.Net;
  11. using MediaBrowser.Controller;
  12. using MediaBrowser.Controller.Configuration;
  13. using MediaBrowser.Controller.Drawing;
  14. using MediaBrowser.Controller.Entities;
  15. using MediaBrowser.Controller.IO;
  16. using MediaBrowser.Controller.Library;
  17. using MediaBrowser.Controller.Localization;
  18. using MediaBrowser.Controller.MediaInfo;
  19. using MediaBrowser.Controller.Persistence;
  20. using MediaBrowser.Controller.Plugins;
  21. using MediaBrowser.Controller.Providers;
  22. using MediaBrowser.Controller.Resolvers;
  23. using MediaBrowser.Controller.Session;
  24. using MediaBrowser.Controller.Sorting;
  25. using MediaBrowser.Controller.Updates;
  26. using MediaBrowser.Controller.Weather;
  27. using MediaBrowser.IsoMounter;
  28. using MediaBrowser.Model.IO;
  29. using MediaBrowser.Model.MediaInfo;
  30. using MediaBrowser.Model.System;
  31. using MediaBrowser.Model.Updates;
  32. using MediaBrowser.Providers;
  33. using MediaBrowser.Server.Implementations;
  34. using MediaBrowser.Server.Implementations.BdInfo;
  35. using MediaBrowser.Server.Implementations.Configuration;
  36. using MediaBrowser.Server.Implementations.HttpServer;
  37. using MediaBrowser.Server.Implementations.IO;
  38. using MediaBrowser.Server.Implementations.Library;
  39. using MediaBrowser.Server.Implementations.Localization;
  40. using MediaBrowser.Server.Implementations.MediaEncoder;
  41. using MediaBrowser.Server.Implementations.Persistence;
  42. using MediaBrowser.Server.Implementations.Providers;
  43. using MediaBrowser.Server.Implementations.ServerManager;
  44. using MediaBrowser.Server.Implementations.Session;
  45. using MediaBrowser.Server.Implementations.Updates;
  46. using MediaBrowser.Server.Implementations.WebSocket;
  47. using MediaBrowser.ServerApplication.Implementations;
  48. using MediaBrowser.WebDashboard.Api;
  49. using System;
  50. using System.Collections.Generic;
  51. using System.Diagnostics;
  52. using System.IO;
  53. using System.Linq;
  54. using System.Reflection;
  55. using System.Threading;
  56. using System.Threading.Tasks;
  57. namespace MediaBrowser.ServerApplication
  58. {
  59. /// <summary>
  60. /// Class CompositionRoot
  61. /// </summary>
  62. public class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>, IServerApplicationHost
  63. {
  64. internal const int UdpServerPort = 7359;
  65. /// <summary>
  66. /// Gets the server kernel.
  67. /// </summary>
  68. /// <value>The server kernel.</value>
  69. protected Kernel ServerKernel { get; set; }
  70. /// <summary>
  71. /// Gets the server configuration manager.
  72. /// </summary>
  73. /// <value>The server configuration manager.</value>
  74. public IServerConfigurationManager ServerConfigurationManager
  75. {
  76. get { return (IServerConfigurationManager)ConfigurationManager; }
  77. }
  78. /// <summary>
  79. /// Gets the name of the log file prefix.
  80. /// </summary>
  81. /// <value>The name of the log file prefix.</value>
  82. protected override string LogFilePrefixName
  83. {
  84. get { return "server"; }
  85. }
  86. /// <summary>
  87. /// Gets the name of the web application that can be used for url building.
  88. /// All api urls will be of the form {protocol}://{host}:{port}/{appname}/...
  89. /// </summary>
  90. /// <value>The name of the web application.</value>
  91. public string WebApplicationName
  92. {
  93. get { return "mediabrowser"; }
  94. }
  95. /// <summary>
  96. /// Gets the HTTP server URL prefix.
  97. /// </summary>
  98. /// <value>The HTTP server URL prefix.</value>
  99. public string HttpServerUrlPrefix
  100. {
  101. get
  102. {
  103. return "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/";
  104. }
  105. }
  106. /// <summary>
  107. /// Gets the configuration manager.
  108. /// </summary>
  109. /// <returns>IConfigurationManager.</returns>
  110. protected override IConfigurationManager GetConfigurationManager()
  111. {
  112. return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
  113. }
  114. /// <summary>
  115. /// Gets or sets the installation manager.
  116. /// </summary>
  117. /// <value>The installation manager.</value>
  118. private IInstallationManager InstallationManager { get; set; }
  119. /// <summary>
  120. /// Gets or sets the server manager.
  121. /// </summary>
  122. /// <value>The server manager.</value>
  123. private IServerManager ServerManager { get; set; }
  124. /// <summary>
  125. /// Gets or sets the user manager.
  126. /// </summary>
  127. /// <value>The user manager.</value>
  128. public IUserManager UserManager { get; set; }
  129. /// <summary>
  130. /// Gets or sets the library manager.
  131. /// </summary>
  132. /// <value>The library manager.</value>
  133. internal ILibraryManager LibraryManager { get; set; }
  134. /// <summary>
  135. /// Gets or sets the directory watchers.
  136. /// </summary>
  137. /// <value>The directory watchers.</value>
  138. private IDirectoryWatchers DirectoryWatchers { get; set; }
  139. /// <summary>
  140. /// Gets or sets the provider manager.
  141. /// </summary>
  142. /// <value>The provider manager.</value>
  143. private IProviderManager ProviderManager { get; set; }
  144. /// <summary>
  145. /// Gets or sets the zip client.
  146. /// </summary>
  147. /// <value>The zip client.</value>
  148. private IZipClient ZipClient { get; set; }
  149. /// <summary>
  150. /// Gets or sets the HTTP server.
  151. /// </summary>
  152. /// <value>The HTTP server.</value>
  153. private IHttpServer HttpServer { get; set; }
  154. /// <summary>
  155. /// Gets or sets the display preferences manager.
  156. /// </summary>
  157. /// <value>The display preferences manager.</value>
  158. internal IDisplayPreferencesManager DisplayPreferencesManager { get; set; }
  159. /// <summary>
  160. /// Gets or sets the media encoder.
  161. /// </summary>
  162. /// <value>The media encoder.</value>
  163. private IMediaEncoder MediaEncoder { get; set; }
  164. private ILocalizationManager LocalizationManager { get; set; }
  165. /// <summary>
  166. /// Gets or sets the user data repository.
  167. /// </summary>
  168. /// <value>The user data repository.</value>
  169. private IUserDataRepository UserDataRepository { get; set; }
  170. private IUserRepository UserRepository { get; set; }
  171. private IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
  172. private IItemRepository ItemRepository { get; set; }
  173. /// <summary>
  174. /// The full path to our startmenu shortcut
  175. /// </summary>
  176. protected override string ProductShortcutPath
  177. {
  178. get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk"); }
  179. }
  180. private Task<IHttpServer> _httpServerCreationTask;
  181. /// <summary>
  182. /// Runs the startup tasks.
  183. /// </summary>
  184. /// <returns>Task.</returns>
  185. public override async Task RunStartupTasks()
  186. {
  187. await base.RunStartupTasks().ConfigureAwait(false);
  188. DirectoryWatchers.Start();
  189. Logger.Info("Core startup complete");
  190. Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint => entryPoint.Run());
  191. }
  192. /// <summary>
  193. /// Called when [logger loaded].
  194. /// </summary>
  195. protected override void OnLoggerLoaded()
  196. {
  197. base.OnLoggerLoaded();
  198. _httpServerCreationTask = Task.Run(() => ServerFactory.CreateServer(this, LogManager, "Media Browser", "dashboard/index.html"));
  199. }
  200. /// <summary>
  201. /// Registers resources that classes will depend on
  202. /// </summary>
  203. /// <returns>Task.</returns>
  204. protected override async Task RegisterResources()
  205. {
  206. ServerKernel = new Kernel();
  207. await base.RegisterResources().ConfigureAwait(false);
  208. RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager));
  209. RegisterSingleInstance<IServerApplicationHost>(this);
  210. RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);
  211. RegisterSingleInstance(ServerKernel);
  212. RegisterSingleInstance(ServerConfigurationManager);
  213. RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
  214. RegisterSingleInstance<IIsoManager>(() => new PismoIsoManager(Logger));
  215. RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
  216. ZipClient = new DotNetZipClient();
  217. RegisterSingleInstance(ZipClient);
  218. UserDataRepository = new SqliteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
  219. RegisterSingleInstance(UserDataRepository);
  220. UserRepository = new SqliteUserRepository(ApplicationPaths, JsonSerializer, LogManager);
  221. RegisterSingleInstance(UserRepository);
  222. DisplayPreferencesRepository = new SqliteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
  223. RegisterSingleInstance(DisplayPreferencesRepository);
  224. ItemRepository = new SqliteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
  225. RegisterSingleInstance(ItemRepository);
  226. UserManager = new UserManager(Logger, ServerConfigurationManager);
  227. RegisterSingleInstance(UserManager);
  228. LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataRepository);
  229. RegisterSingleInstance(LibraryManager);
  230. InstallationManager = new InstallationManager(HttpClient, PackageManager, JsonSerializer, Logger, this);
  231. RegisterSingleInstance(InstallationManager);
  232. DirectoryWatchers = new DirectoryWatchers(LogManager, TaskManager, LibraryManager, ServerConfigurationManager);
  233. RegisterSingleInstance(DirectoryWatchers);
  234. ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, DirectoryWatchers, LogManager);
  235. RegisterSingleInstance(ProviderManager);
  236. DisplayPreferencesManager = new DisplayPreferencesManager(LogManager.GetLogger("DisplayPreferencesManager"));
  237. RegisterSingleInstance(DisplayPreferencesManager);
  238. RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager));
  239. MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ZipClient, ApplicationPaths, JsonSerializer);
  240. RegisterSingleInstance(MediaEncoder);
  241. var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository);
  242. RegisterSingleInstance<ISessionManager>(clientConnectionManager);
  243. HttpServer = await _httpServerCreationTask.ConfigureAwait(false);
  244. RegisterSingleInstance(HttpServer, false);
  245. ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager);
  246. RegisterSingleInstance(ServerManager);
  247. LocalizationManager = new LocalizationManager(ServerConfigurationManager);
  248. RegisterSingleInstance(LocalizationManager);
  249. var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
  250. var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
  251. var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));
  252. var userTask = Task.Run(async () => await ConfigureUserRepositories().ConfigureAwait(false));
  253. await Task.WhenAll(itemsTask, userTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
  254. SetKernelProperties();
  255. }
  256. /// <summary>
  257. /// Sets the kernel properties.
  258. /// </summary>
  259. private void SetKernelProperties()
  260. {
  261. ServerKernel.ImageManager = new ImageManager(ServerKernel, LogManager.GetLogger("ImageManager"),
  262. ApplicationPaths);
  263. Parallel.Invoke(
  264. () => ServerKernel.FFMpegManager = new FFMpegManager(ApplicationPaths, MediaEncoder, LibraryManager, Logger),
  265. () => ServerKernel.WeatherProviders = GetExports<IWeatherProvider>(),
  266. () => ServerKernel.ImageManager.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
  267. () => LocalizedStrings.StringFiles = GetExports<LocalizedStringData>(),
  268. SetStaticProperties
  269. );
  270. }
  271. /// <summary>
  272. /// Configures the repositories.
  273. /// </summary>
  274. /// <returns>Task.</returns>
  275. private async Task ConfigureDisplayPreferencesRepositories()
  276. {
  277. await DisplayPreferencesRepository.Initialize().ConfigureAwait(false);
  278. ((DisplayPreferencesManager)DisplayPreferencesManager).Repository = DisplayPreferencesRepository;
  279. }
  280. /// <summary>
  281. /// Configures the item repositories.
  282. /// </summary>
  283. /// <returns>Task.</returns>
  284. private async Task ConfigureItemRepositories()
  285. {
  286. await ItemRepository.Initialize().ConfigureAwait(false);
  287. ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
  288. }
  289. /// <summary>
  290. /// Configures the user data repositories.
  291. /// </summary>
  292. /// <returns>Task.</returns>
  293. private Task ConfigureUserDataRepositories()
  294. {
  295. return UserDataRepository.Initialize();
  296. }
  297. /// <summary>
  298. /// Configures the user repositories.
  299. /// </summary>
  300. /// <returns>Task.</returns>
  301. private async Task ConfigureUserRepositories()
  302. {
  303. await UserRepository.Initialize().ConfigureAwait(false);
  304. ((UserManager)UserManager).UserRepository = UserRepository;
  305. }
  306. /// <summary>
  307. /// Dirty hacks
  308. /// </summary>
  309. private void SetStaticProperties()
  310. {
  311. // For now there's no real way to inject these properly
  312. BaseItem.Logger = LogManager.GetLogger("BaseItem");
  313. BaseItem.ConfigurationManager = ServerConfigurationManager;
  314. BaseItem.LibraryManager = LibraryManager;
  315. BaseItem.ProviderManager = ProviderManager;
  316. BaseItem.LocalizationManager = LocalizationManager;
  317. User.XmlSerializer = XmlSerializer;
  318. User.UserManager = UserManager;
  319. LocalizedStrings.ApplicationPaths = ApplicationPaths;
  320. }
  321. /// <summary>
  322. /// Finds the parts.
  323. /// </summary>
  324. protected override void FindParts()
  325. {
  326. if (IsFirstRun)
  327. {
  328. RegisterServerWithAdministratorAccess();
  329. }
  330. base.FindParts();
  331. HttpServer.Init(GetExports<IRestfulService>(false));
  332. ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
  333. StartServer(true);
  334. LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
  335. GetExports<IVirtualFolderCreator>(),
  336. GetExports<IItemResolver>(),
  337. GetExports<IIntroProvider>(),
  338. GetExports<IBaseItemComparer>(),
  339. GetExports<ILibraryPrescanTask>(),
  340. GetExports<ILibraryPostScanTask>(),
  341. GetExports<IMetadataSaver>());
  342. ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().ToArray());
  343. }
  344. /// <summary>
  345. /// Starts the server.
  346. /// </summary>
  347. /// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
  348. private void StartServer(bool retryOnFailure)
  349. {
  350. try
  351. {
  352. ServerManager.Start();
  353. }
  354. catch
  355. {
  356. if (retryOnFailure)
  357. {
  358. RegisterServerWithAdministratorAccess();
  359. StartServer(false);
  360. }
  361. else
  362. {
  363. throw;
  364. }
  365. }
  366. }
  367. /// <summary>
  368. /// Called when [configuration updated].
  369. /// </summary>
  370. /// <param name="sender">The sender.</param>
  371. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  372. protected override void OnConfigurationUpdated(object sender, EventArgs e)
  373. {
  374. base.OnConfigurationUpdated(sender, e);
  375. if (!string.Equals(HttpServer.UrlPrefix, HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
  376. {
  377. NotifyPendingRestart();
  378. }
  379. else if (!ServerManager.SupportsNativeWebSocket && ServerManager.WebSocketPortNumber != ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber)
  380. {
  381. NotifyPendingRestart();
  382. }
  383. }
  384. /// <summary>
  385. /// Restarts this instance.
  386. /// </summary>
  387. public override void Restart()
  388. {
  389. App.Instance.Restart();
  390. }
  391. /// <summary>
  392. /// Gets or sets a value indicating whether this instance can self update.
  393. /// </summary>
  394. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  395. public override bool CanSelfUpdate
  396. {
  397. get { return ConfigurationManager.CommonConfiguration.EnableAutoUpdate; }
  398. }
  399. /// <summary>
  400. /// Checks for update.
  401. /// </summary>
  402. /// <param name="cancellationToken">The cancellation token.</param>
  403. /// <param name="progress">The progress.</param>
  404. /// <returns>Task{CheckForUpdateResult}.</returns>
  405. public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
  406. {
  407. var availablePackages = await PackageManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
  408. var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
  409. return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
  410. new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
  411. }
  412. /// <summary>
  413. /// Gets the composable part assemblies.
  414. /// </summary>
  415. /// <returns>IEnumerable{Assembly}.</returns>
  416. protected override IEnumerable<Assembly> GetComposablePartAssemblies()
  417. {
  418. // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
  419. // This will prevent the .dll file from getting locked, and allow us to replace it when needed
  420. foreach (var pluginAssembly in Directory
  421. .EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
  422. .Select(LoadAssembly).Where(a => a != null))
  423. {
  424. yield return pluginAssembly;
  425. }
  426. // Include composable parts in the Api assembly
  427. yield return typeof(ApiEntryPoint).Assembly;
  428. // Include composable parts in the Dashboard assembly
  429. yield return typeof(DashboardInfo).Assembly;
  430. // Include composable parts in the Model assembly
  431. yield return typeof(SystemInfo).Assembly;
  432. // Include composable parts in the Common assembly
  433. yield return typeof(IApplicationHost).Assembly;
  434. // Include composable parts in the Controller assembly
  435. yield return typeof(Kernel).Assembly;
  436. // Include composable parts in the Providers assembly
  437. yield return typeof(ImagesByNameProvider).Assembly;
  438. // Common implementations
  439. yield return typeof(TaskManager).Assembly;
  440. // Server implementations
  441. yield return typeof(ServerApplicationPaths).Assembly;
  442. // Include composable parts in the running assembly
  443. yield return GetType().Assembly;
  444. }
  445. private readonly string _systemId = Environment.MachineName.GetMD5().ToString();
  446. /// <summary>
  447. /// Gets the system status.
  448. /// </summary>
  449. /// <returns>SystemInfo.</returns>
  450. public virtual SystemInfo GetSystemInfo()
  451. {
  452. return new SystemInfo
  453. {
  454. HasPendingRestart = HasPendingRestart,
  455. Version = ApplicationVersion.ToString(),
  456. IsNetworkDeployed = CanSelfUpdate,
  457. WebSocketPortNumber = ServerManager.WebSocketPortNumber,
  458. SupportsNativeWebSocket = ServerManager.SupportsNativeWebSocket,
  459. FailedPluginAssemblies = FailedAssemblies.ToArray(),
  460. InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToArray(),
  461. CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
  462. Id = _systemId,
  463. ProgramDataPath = ApplicationPaths.ProgramDataPath
  464. };
  465. }
  466. /// <summary>
  467. /// Shuts down.
  468. /// </summary>
  469. public override void Shutdown()
  470. {
  471. App.Instance.Dispatcher.Invoke(App.Instance.Shutdown);
  472. }
  473. /// <summary>
  474. /// Registers the server with administrator access.
  475. /// </summary>
  476. private void RegisterServerWithAdministratorAccess()
  477. {
  478. Logger.Info("Requesting administrative access to authorize http server");
  479. // Create a temp file path to extract the bat file to
  480. var tmpFile = Path.Combine(ConfigurationManager.CommonApplicationPaths.TempDirectory, Guid.NewGuid() + ".bat");
  481. // Extract the bat file
  482. using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.ServerApplication.RegisterServer.bat"))
  483. {
  484. using (var fileStream = File.Create(tmpFile))
  485. {
  486. stream.CopyTo(fileStream);
  487. }
  488. }
  489. var startInfo = new ProcessStartInfo
  490. {
  491. FileName = tmpFile,
  492. Arguments = string.Format("{0} {1} {2} {3}", ServerConfigurationManager.Configuration.HttpServerPortNumber,
  493. HttpServerUrlPrefix,
  494. UdpServerPort,
  495. ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber),
  496. CreateNoWindow = true,
  497. WindowStyle = ProcessWindowStyle.Hidden,
  498. Verb = "runas",
  499. ErrorDialog = false
  500. };
  501. using (var process = Process.Start(startInfo))
  502. {
  503. process.WaitForExit();
  504. }
  505. }
  506. }
  507. }