public async Task <IActionResult> Warmup([FromServices] IScriptHostManager scriptHostManager) { // Endpoint only for Windows Elastic Premium or Linux App Service plans if (!(_environment.IsLinuxAppService() || _environment.IsWindowsElasticPremium())) { return(BadRequest("This API is not available for the current hosting plan")); } if (Interlocked.CompareExchange(ref _warmupExecuted, 1, 0) != 0) { return(Ok()); } if (scriptHostManager is IServiceProvider serviceProvider) { IScriptJobHost jobHost = serviceProvider.GetService <IScriptJobHost>(); if (jobHost == null) { _logger.LogError($"No active host available."); return(StatusCode(503)); } await jobHost.TryInvokeWarmupAsync(); return(Ok()); } return(BadRequest("This API is not supported by the current hosting environment.")); }
public async Task <IActionResult> Warmup([FromServices] IScriptJobHost scriptHost) { await scriptHost.TryInvokeWarmupAsync(); return(Ok()); }