怎么建设网站怎么样,如何做网站内部优化,做公益网站有什么要求,广告接单有什么平台有些时候需要在程序中启动和管理其他应用进程#xff0c;当碰到这样的需求的时候可以通过Process对象来完成#xff1b;为了让使用和管理更方便在这基础上封装 了BeetleX.ServicesProcess组件#xff0c;通过组件的管理中心让进程操作更方便#xff0c;同时还集成了Web套件… 有些时候需要在程序中启动和管理其他应用进程当碰到这样的需求的时候可以通过Process对象来完成为了让使用和管理更方便在这基础上封装 了BeetleX.ServicesProcess组件通过组件的管理中心让进程操作更方便同时还集成了Web套件可直接集成在BeetleX.FastHttpApi中进行Web管理。 BeetleX.ServicesProcess组件提供了ProcessCenter对象来添加管理启动和停止等进程管理功能。具体功能方法如下:public class ProcessCenter : IDisposable{public ProcessCenter();public ProcessCenter(ILogHandler logHandler);public ServiceManagementConfig Config { get; }public void Add(string name, string file, string path, string args, bool autoStartup false);public void Add(ProcessInfo info);public void AutoStartup();public void ChangeUser(string admin, string pwd);public void Delete(string id);public void Dispose();public ServiceProcess GetProcess(string id);public void Modify(string id, ProcessInfo info);public void Start(string id);public void StartAll();public void Stop(string id);public void StopAll();}以上是组件封装的方法使用起来非常简单。 接下来主要介绍如何在BeetleX.FastHttpApi中集成它的web管理功能创建一个控制台项目引用BeetleX.WebFamily组件引用后编写以下代码class Program{static void Main(string[] args){WebHost host new WebHost();host.IsWindowsServices true;WebHost.Title Service Management;WebHost.HeaderModel beetlex-process-header;WebHost.HomeModel beetlex-process-home;WebHost.TabsEnabled false;host.RegisterComponentProgram();host.RegisterComponentBeetleX.ServicesProcess.ProcessCenter();host.UseFontawesome();host.UseElement(PageStyle.Element);host.Setting(o {o.SetDebug();o.Port 80;o.LogLevel LogType.Info;});host.Initialize((http, vue, rec) {BeetleX.ServicesProcess.WebController controller new BeetleX.ServicesProcess.WebController();controller.Init(new logHandler(http));http.ActionFactory.Register(controller, new BeetleX.FastHttpApi.ControllerAttribute { BaseUrl process });rec.AddCss(website.css);vue.Debug();});host.Run();}}class logHandler : BeetleX.ServicesProcess.ILogHandler{public logHandler(BeetleX.FastHttpApi.HttpApiServer sever){mServer sever;}private BeetleX.FastHttpApi.HttpApiServer mServer;public void Error(string message){mServer.GetLog(LogType.Error)?.Log(LogType.Error, null, message);}public void Info(string message){mServer.GetLog(LogType.Info)?.Log(LogType.Info, null, message);}}启动项目后可以查看启动日志接下来就可以通过浏览器访问进程管理页面如果有需要还可以把当前示例项目发布成windows service发布后即可以使用sc命令来创建、启动、停止和删除服务。完整示例代码https://github.com/beetlex-io/BeetleX-Samples/tree/master/Web.ServiceManagement