protected override Task ExecuteAsync(CancellationToken stoppingToken) { try { ExposeNssmExe(); var port = System.Configuration.ConfigurationManager.AppSettings["Port"]; TinyFoxService.OwinOnly = true; TinyFoxService.IpAddress = TyeIpAddress.Any; TinyFoxService.Port = string.IsNullOrEmpty(port) ? 8088 : int.Parse(port); _startup = new AntDeployAgentWindows.Startup(); TinyFoxService.Start(_startup.OwinMain); } catch (Exception ex) { _logger.LogError(ex, "StartError"); try { File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "startupError.txt"), ex.ToString()); } catch (Exception) { } } return(Task.CompletedTask); }
protected override void OnStart(string[] args) { var port = System.Configuration.ConfigurationManager.AppSettings["Port"]; TinyFoxService.Port = string.IsNullOrEmpty(port) ? 8088 : int.Parse(port); _startup = new AntDeployAgentWindows.Startup(); TinyFoxService.Start(_startup.OwinMain); }
static void Main(string[] args) { TinyFoxService.Port = 8080; TinyFoxService.Start(new Startup().OwinMain); while (true) { Thread.Sleep(1000); } }
static void Main(string[] args) { //设置端口(默认端口为8088) TinyFoxService.Port = 8080; //设置网站文件夹路路径(默认本exe所在程序下的 wwwroot 目录) //TinyFoxService.WebRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot"); //启动(非阻塞) TinyFoxService.Start((new Startup()).OwinMain); //提示并等候终止 Console.WriteLine("按 CTRL+C 退出程序"); (new AutoResetEvent(false)).WaitOne(); //停止OWIN服务 TinyFoxService.Stop(); }
public Task StartAsync(CancellationToken cancellationToken) { try { var port = System.Configuration.ConfigurationManager.AppSettings["Port"]; TinyFoxService.Port = string.IsNullOrEmpty(port) ? 8088 : int.Parse(port); _startup = new AntDeployAgentWindows.Startup(); TinyFoxService.Start(_startup.OwinMain); } catch (Exception ex) { try { File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "startupError.txt"), ex.ToString()); } catch (Exception) { } } return(Task.CompletedTask); }
static void Main(string[] args) { //-------------------------------------------------------- // * OWIN WEB服务配置与启动 //-------------------------------------------------------- // 一个启动对象 var startup = new Startup(); var port = System.Configuration.ConfigurationManager.AppSettings["Port"]; TinyFoxService.Port = string.IsNullOrEmpty(port)?8088:int.Parse(port); //服务端口(默认是8088) //TinyFoxService.WebRoot = @"A:\Users\Administrator\AppData\Local\tx\1877682825\FileRecv\TinyFox181113\TinyFox\Demo\Demo0\bin\Debug\site"; //网站根文件夹(默认路径是:应用程序/site/wwwroot) // 启动服务 TinyFoxService.Start(startup.OwinMain); //启动服务(非阻塞的) //---------------------------------------------------- // * 等候退出 //----------------------------------------------------- Console.WriteLine("如要退出,请按 Ctrl+c 键"); //提示 (new AutoResetEvent(false)).WaitOne(); //阻塞与等候 Console.WriteLine("正在退出,拜拜!"); //提示 TinyFoxService.Stop(); //这句还是比较重要的 }