ApplicationHost.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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.Providers;
  42. using MediaBrowser.Server.Implementations.ServerManager;
  43. using MediaBrowser.Server.Implementations.Session;
  44. using MediaBrowser.Server.Implementations.Sqlite;
  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. /// <summary>
  165. /// Gets or sets the user data repository.
  166. /// </summary>
  167. /// <value>The user data repository.</value>
  168. private IUserDataRepository UserDataRepository { get; set; }
  169. private IUserRepository UserRepository { get; set; }
  170. private IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
  171. private IItemRepository ItemRepository { get; set; }
  172. /// <summary>
  173. /// The full path to our startmenu shortcut
  174. /// </summary>
  175. protected override string ProductShortcutPath
  176. {
  177. get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk"); }
  178. }
  179. private Task<IHttpServer> _httpServerCreationTask;
  180. /// <summary>
  181. /// Runs the startup tasks.
  182. /// </summary>
  183. /// <returns>Task.</returns>
  184. public override async Task RunStartupTasks()
  185. {
  186. await base.RunStartupTasks().ConfigureAwait(false);
  187. DirectoryWatchers.Start();
  188. Logger.Info("Core startup complete");
  189. Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint => entryPoint.Run());
  190. }
  191. /// <summary>
  192. /// Called when [logger loaded].
  193. /// </summary>
  194. protected override void OnLoggerLoaded()
  195. {
  196. base.OnLoggerLoaded();
  197. _httpServerCreationTask = Task.Run(() => ServerFactory.CreateServer(this, LogManager, "Media Browser", "dashboard/index.html"));
  198. }
  199. /// <summary>
  200. /// Registers resources that classes will depend on
  201. /// </summary>
  202. /// <returns>Task.</returns>
  203. protected override async Task RegisterResources()
  204. {
  205. ServerKernel = new Kernel();
  206. await base.RegisterResources().ConfigureAwait(false);
  207. RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager));
  208. RegisterSingleInstance<IServerApplicationHost>(this);
  209. RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);
  210. RegisterSingleInstance(ServerKernel);
  211. RegisterSingleInstance(ServerConfigurationManager);
  212. RegisterSingleInstance<IWebSocketServer>(() => new AlchemyServer(Logger));
  213. RegisterSingleInstance<IIsoManager>(() => new PismoIsoManager(Logger));
  214. RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
  215. ZipClient = new DotNetZipClient();
  216. RegisterSingleInstance(ZipClient);
  217. UserDataRepository = new SQLiteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
  218. RegisterSingleInstance(UserDataRepository);
  219. UserRepository = new SQLiteUserRepository(ApplicationPaths, JsonSerializer, LogManager);
  220. RegisterSingleInstance(UserRepository);
  221. DisplayPreferencesRepository = new SQLiteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
  222. RegisterSingleInstance(DisplayPreferencesRepository);
  223. ItemRepository = new SQLiteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
  224. RegisterSingleInstance(ItemRepository);
  225. UserManager = new UserManager(Logger, ServerConfigurationManager);
  226. RegisterSingleInstance(UserManager);
  227. LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataRepository);
  228. RegisterSingleInstance(LibraryManager);
  229. InstallationManager = new InstallationManager(HttpClient, PackageManager, JsonSerializer, Logger, this);
  230. RegisterSingleInstance(InstallationManager);
  231. DirectoryWatchers = new DirectoryWatchers(LogManager, TaskManager, LibraryManager, ServerConfigurationManager);
  232. RegisterSingleInstance(DirectoryWatchers);
  233. ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, DirectoryWatchers, LogManager);
  234. RegisterSingleInstance(ProviderManager);
  235. DisplayPreferencesManager = new DisplayPreferencesManager(LogManager.GetLogger("DisplayPreferencesManager"));
  236. RegisterSingleInstance(DisplayPreferencesManager);
  237. RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager));
  238. MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ZipClient, ApplicationPaths, JsonSerializer);
  239. RegisterSingleInstance(MediaEncoder);
  240. var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository);
  241. RegisterSingleInstance<ISessionManager>(clientConnectionManager);
  242. HttpServer = await _httpServerCreationTask.ConfigureAwait(false);
  243. RegisterSingleInstance(HttpServer, false);
  244. ServerManager = new ServerManager(this, JsonSerializer, Logger, ServerConfigurationManager);
  245. RegisterSingleInstance(ServerManager);
  246. var localizationManager = new LocalizationManager();
  247. RegisterSingleInstance<ILocalizationManager>(localizationManager);
  248. var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
  249. var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
  250. var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));
  251. var userTask = Task.Run(async () => await ConfigureUserRepositories().ConfigureAwait(false));
  252. await Task.WhenAll(itemsTask, userTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
  253. SetKernelProperties();
  254. }
  255. /// <summary>
  256. /// Sets the kernel properties.
  257. /// </summary>
  258. private void SetKernelProperties()
  259. {
  260. ServerKernel.ImageManager = new ImageManager(ServerKernel, LogManager.GetLogger("ImageManager"),
  261. ApplicationPaths);
  262. Parallel.Invoke(
  263. () => ServerKernel.FFMpegManager = new FFMpegManager(ApplicationPaths, MediaEncoder, LibraryManager, Logger),
  264. () => ServerKernel.WeatherProviders = GetExports<IWeatherProvider>(),
  265. () => ServerKernel.ImageManager.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
  266. () => LocalizedStrings.StringFiles = GetExports<LocalizedStringData>(),
  267. SetStaticProperties
  268. );
  269. }
  270. /// <summary>
  271. /// Configures the repositories.
  272. /// </summary>
  273. /// <returns>Task.</returns>
  274. private async Task ConfigureDisplayPreferencesRepositories()
  275. {
  276. await DisplayPreferencesRepository.Initialize().ConfigureAwait(false);
  277. ((DisplayPreferencesManager)DisplayPreferencesManager).Repository = DisplayPreferencesRepository;
  278. }
  279. /// <summary>
  280. /// Configures the item repositories.
  281. /// </summary>
  282. /// <returns>Task.</returns>
  283. private async Task ConfigureItemRepositories()
  284. {
  285. await ItemRepository.Initialize().ConfigureAwait(false);
  286. ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
  287. }
  288. /// <summary>
  289. /// Configures the user data repositories.
  290. /// </summary>
  291. /// <returns>Task.</returns>
  292. private Task ConfigureUserDataRepositories()
  293. {
  294. return UserDataRepository.Initialize();
  295. }
  296. /// <summary>
  297. /// Configures the user repositories.
  298. /// </summary>
  299. /// <returns>Task.</returns>
  300. private async Task ConfigureUserRepositories()
  301. {
  302. await UserRepository.Initialize().ConfigureAwait(false);
  303. ((UserManager)UserManager).UserRepository = UserRepository;
  304. }
  305. /// <summary>
  306. /// Dirty hacks
  307. /// </summary>
  308. private void SetStaticProperties()
  309. {
  310. // For now there's no real way to inject these properly
  311. BaseItem.Logger = LogManager.GetLogger("BaseItem");
  312. BaseItem.ConfigurationManager = ServerConfigurationManager;
  313. BaseItem.LibraryManager = LibraryManager;
  314. BaseItem.ProviderManager = ProviderManager;
  315. User.XmlSerializer = XmlSerializer;
  316. User.UserManager = UserManager;
  317. Ratings.ConfigurationManager = ServerConfigurationManager;
  318. LocalizedStrings.ApplicationPaths = ApplicationPaths;
  319. }
  320. /// <summary>
  321. /// Finds the parts.
  322. /// </summary>
  323. protected override void FindParts()
  324. {
  325. if (IsFirstRun)
  326. {
  327. RegisterServerWithAdministratorAccess();
  328. }
  329. base.FindParts();
  330. HttpServer.Init(GetExports<IRestfulService>(false));
  331. ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
  332. StartServer(true);
  333. LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
  334. GetExports<IVirtualFolderCreator>(),
  335. GetExports<IItemResolver>(),
  336. GetExports<IIntroProvider>(),
  337. GetExports<IBaseItemComparer>(),
  338. GetExports<ILibraryPrescanTask>(),
  339. GetExports<ILibraryPostScanTask>());
  340. ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().ToArray());
  341. }
  342. /// <summary>
  343. /// Starts the server.
  344. /// </summary>
  345. /// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
  346. private void StartServer(bool retryOnFailure)
  347. {
  348. try
  349. {
  350. ServerManager.Start();
  351. }
  352. catch
  353. {
  354. if (retryOnFailure)
  355. {
  356. RegisterServerWithAdministratorAccess();
  357. StartServer(false);
  358. }
  359. else
  360. {
  361. throw;
  362. }
  363. }
  364. }
  365. /// <summary>
  366. /// Called when [configuration updated].
  367. /// </summary>
  368. /// <param name="sender">The sender.</param>
  369. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  370. protected override void OnConfigurationUpdated(object sender, EventArgs e)
  371. {
  372. base.OnConfigurationUpdated(sender, e);
  373. if (!string.Equals(HttpServer.UrlPrefix, HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
  374. {
  375. NotifyPendingRestart();
  376. }
  377. else if (!ServerManager.SupportsNativeWebSocket && ServerManager.WebSocketPortNumber != ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber)
  378. {
  379. NotifyPendingRestart();
  380. }
  381. }
  382. /// <summary>
  383. /// Restarts this instance.
  384. /// </summary>
  385. public override void Restart()
  386. {
  387. App.Instance.Restart();
  388. }
  389. /// <summary>
  390. /// Gets or sets a value indicating whether this instance can self update.
  391. /// </summary>
  392. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  393. public override bool CanSelfUpdate
  394. {
  395. get { return ConfigurationManager.CommonConfiguration.EnableAutoUpdate; }
  396. }
  397. /// <summary>
  398. /// Checks for update.
  399. /// </summary>
  400. /// <param name="cancellationToken">The cancellation token.</param>
  401. /// <param name="progress">The progress.</param>
  402. /// <returns>Task{CheckForUpdateResult}.</returns>
  403. public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
  404. {
  405. var availablePackages = await PackageManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
  406. var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
  407. return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
  408. new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
  409. }
  410. /// <summary>
  411. /// Gets the composable part assemblies.
  412. /// </summary>
  413. /// <returns>IEnumerable{Assembly}.</returns>
  414. protected override IEnumerable<Assembly> GetComposablePartAssemblies()
  415. {
  416. // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
  417. // This will prevent the .dll file from getting locked, and allow us to replace it when needed
  418. foreach (var pluginAssembly in Directory
  419. .EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
  420. .Select(LoadAssembly).Where(a => a != null))
  421. {
  422. yield return pluginAssembly;
  423. }
  424. // Include composable parts in the Api assembly
  425. yield return typeof(ApiEntryPoint).Assembly;
  426. // Include composable parts in the Dashboard assembly
  427. yield return typeof(DashboardInfo).Assembly;
  428. // Include composable parts in the Model assembly
  429. yield return typeof(SystemInfo).Assembly;
  430. // Include composable parts in the Common assembly
  431. yield return typeof(IApplicationHost).Assembly;
  432. // Include composable parts in the Controller assembly
  433. yield return typeof(Kernel).Assembly;
  434. // Include composable parts in the Providers assembly
  435. yield return typeof(ImagesByNameProvider).Assembly;
  436. // Common implementations
  437. yield return typeof(TaskManager).Assembly;
  438. // Server implementations
  439. yield return typeof(ServerApplicationPaths).Assembly;
  440. // Include composable parts in the running assembly
  441. yield return GetType().Assembly;
  442. }
  443. private readonly string _systemId = Environment.MachineName.GetMD5().ToString();
  444. /// <summary>
  445. /// Gets the system status.
  446. /// </summary>
  447. /// <returns>SystemInfo.</returns>
  448. public virtual SystemInfo GetSystemInfo()
  449. {
  450. return new SystemInfo
  451. {
  452. HasPendingRestart = HasPendingRestart,
  453. Version = ApplicationVersion.ToString(),
  454. IsNetworkDeployed = CanSelfUpdate,
  455. WebSocketPortNumber = ServerManager.WebSocketPortNumber,
  456. SupportsNativeWebSocket = ServerManager.SupportsNativeWebSocket,
  457. FailedPluginAssemblies = FailedAssemblies.ToArray(),
  458. InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToArray(),
  459. CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
  460. Id = _systemId,
  461. ProgramDataPath = ApplicationPaths.ProgramDataPath
  462. };
  463. }
  464. /// <summary>
  465. /// Shuts down.
  466. /// </summary>
  467. public override void Shutdown()
  468. {
  469. App.Instance.Dispatcher.Invoke(App.Instance.Shutdown);
  470. }
  471. /// <summary>
  472. /// Registers the server with administrator access.
  473. /// </summary>
  474. private void RegisterServerWithAdministratorAccess()
  475. {
  476. Logger.Info("Requesting administrative access to authorize http server");
  477. // Create a temp file path to extract the bat file to
  478. var tmpFile = Path.Combine(ConfigurationManager.CommonApplicationPaths.TempDirectory, Guid.NewGuid() + ".bat");
  479. // Extract the bat file
  480. using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.ServerApplication.RegisterServer.bat"))
  481. {
  482. using (var fileStream = File.Create(tmpFile))
  483. {
  484. stream.CopyTo(fileStream);
  485. }
  486. }
  487. var startInfo = new ProcessStartInfo
  488. {
  489. FileName = tmpFile,
  490. Arguments = string.Format("{0} {1} {2} {3}", ServerConfigurationManager.Configuration.HttpServerPortNumber,
  491. HttpServerUrlPrefix,
  492. UdpServerPort,
  493. ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber),
  494. CreateNoWindow = true,
  495. WindowStyle = ProcessWindowStyle.Hidden,
  496. Verb = "runas",
  497. ErrorDialog = false
  498. };
  499. using (var process = Process.Start(startInfo))
  500. {
  501. process.WaitForExit();
  502. }
  503. }
  504. }
  505. }