zoukankan      html  css  js  c++  java
  • 认识一般主机的注入windows service

    使用topself,因为我太蠢了,所以经常会1064或者是1053,最近花了1-2天才搞清楚在使用topself的时候应该怎么写。

    Microsoft.Extensions.Hosting.IHost,

    HostFactory.Run(x =>
    {
    x.Service<IHost>(s =>
    {
    s.ConstructUsing(() => Start00(fileroot, args, Log.Logger).Build());
    s.WhenStarted(service =>
    {
    service.Start();//主机同步调用
    });
    s.WhenStopped(async service =>
    {
    await service.StopAsync();
    });
    });

    //x.Service(s => new MainSiloServiceControl(fileroot, Log.Logger,args));
    //x.Service<HYWServiceControl>();
    x.EnableServiceRecovery(r => r.RestartService(TimeSpan.FromMinutes(1)));
    x.RunAsLocalSystem();
    x.SetDisplayName("路径测试员V2");
    x.SetServiceName("路径测试员V2");
    x.RunAsLocalService();
    x.StartAutomaticallyDelayed();
    });

    见使用orleans的通用主机的例子。主要是为了看asp.net core是怎么配置的。

    var host = new HostBuilder()
      .ConfigureWebHostDefaults(webBuilder =>
      {
        // Configure ASP.NET Core
        webBuilder.UseStartup<Startup>();
      })
      .UseOrleans(siloBuilder =>
      {
        // Configure Orleans
        siloBuilder.UseLocalHostClustering();
      })
      .ConfigureLogging(logging =>
      {
        /* Configure cross-cutting concerns such as logging */
      })
      .ConfigureServices(services =>
      {
        /* Configure shared services */
      })
      .UseConsoleLifetime()
      .Build();
    
    // Start the host and wait for it to stop.
    await host.RunAsync();
    蠢人记录
  • 相关阅读:
    java基础---->摘要算法的介绍
    startActivityForResult的用法和demo
    Java 获取类名,函数名,行数
    android ListView详解继承ListActivity
    Java List 如何传值
    synchronized的使用方法
    StringUtil
    【转】Java 5种字符串拼接方式性能比较。
    [Android] Intent详解
    TabHost详解
  • 原文地址:https://www.cnblogs.com/forhell/p/14335761.html
Copyright © 2011-2022 走看看