【问题标题】:Multiple hangfire dashboards and processing on the same server at the same time多个hangfire仪表板并同时在同一台服务器上处理
【发布时间】:2020-09-06 23:25:48
【问题描述】:

我们的登台和生产实例位于同一台服务器上(使用单个 IIS)。因此,我们在这台电脑上安装了一个挂火服务器,用于暂存和管理生产。

但是,由于存在冲突,我们不能同时运行暂存版本和生产版本的 hang-fire,因此我们需要始终停止其中一个。

这两种处理都适用于不同的数据库并处理配置文件配置的不同项目。

在同一台服务器上基本上有 2 个hangfire 仪表板和相关处理吗?

【问题讨论】:

    标签: hangfire


    【解决方案1】:

    所以我的问题有点不对劲。我们需要在不同的端口上运行的不是hangfire,而是用于托管它的进程。

    在这种情况下,我们将 hangfire 作为 Windows 服务运行。

    host.RunAsService();
    

    但是,默认情况下,它使用端口 5000。因此,当我们运行 2 个 Windows 服务时,它们在此端口上发生冲突。

    我们需要做的是配置我们的主机服务器以在不同的端口上运行这些实例。我们可以通过将端口配置添加到我们的 appsettings 并进行相应设置来做到这一点。然后我们可以在启动时读取它来配置使用的 Url。

        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            var config = new ConfigurationBuilder()
                .AddJsonFile("appsettings.json", optional: true); //this is not needed, but could be useful
    
            var settings = new ProcessingSettings();
            config.Build().GetSection("ProcessingSettings").Bind(settings);
    
            return WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseUrls($"http://*:{settings.Port}");
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      • 2012-03-22
      • 2016-02-20
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多