2
2
// Licensed under the MIT License. See License.txt in the project root for license information.
3
3
4
4
using System ;
5
+ using System . Collections . Generic ;
5
6
using System . IO ;
7
+ using System . Reactive . Linq ;
6
8
using System . Threading ;
7
9
using System . Threading . Tasks ;
10
+ using Microsoft . Azure . WebJobs . Script . Eventing ;
11
+ using Microsoft . Azure . WebJobs . Script . Rpc ;
8
12
using Microsoft . Azure . WebJobs . Script . WebHost . Properties ;
9
13
using Microsoft . Extensions . Configuration ;
10
14
using Microsoft . Extensions . FileProviders ;
@@ -24,17 +28,17 @@ public class StandbyManager : IStandbyManager
24
28
private readonly Lazy < Task > _specializationTask ;
25
29
private readonly IScriptWebHostEnvironment _webHostEnvironment ;
26
30
private readonly IEnvironment _environment ;
31
+ private readonly ILanguageWorkerChannelManager _languageWorkerChannelManager ;
27
32
private readonly IConfigurationRoot _configuration ;
28
33
private readonly ILogger _logger ;
29
-
30
34
private readonly TimeSpan _specializationTimerInterval = TimeSpan . FromMilliseconds ( 500 ) ;
31
- private Timer _specializationTimer ;
32
35
36
+ private Timer _specializationTimer ;
33
37
private static CancellationTokenSource _standbyCancellationTokenSource = new CancellationTokenSource ( ) ;
34
38
private static IChangeToken _standbyChangeToken = new CancellationChangeToken ( _standbyCancellationTokenSource . Token ) ;
35
39
private static SemaphoreSlim _semaphore = new SemaphoreSlim ( 1 , 1 ) ;
36
40
37
- public StandbyManager ( IScriptHostManager scriptHostManager , IConfiguration configuration , IScriptWebHostEnvironment webHostEnvironment ,
41
+ public StandbyManager ( IScriptHostManager scriptHostManager , ILanguageWorkerChannelManager languageWorkerChannelManager , IConfiguration configuration , IScriptWebHostEnvironment webHostEnvironment ,
38
42
IEnvironment environment , IOptionsMonitor < ScriptApplicationHostOptions > options , ILogger < StandbyManager > logger )
39
43
{
40
44
_scriptHostManager = scriptHostManager ?? throw new ArgumentNullException ( nameof ( scriptHostManager ) ) ;
@@ -43,8 +47,8 @@ public StandbyManager(IScriptHostManager scriptHostManager, IConfiguration confi
43
47
_specializationTask = new Lazy < Task > ( SpecializeHostCoreAsync , LazyThreadSafetyMode . ExecutionAndPublication ) ;
44
48
_webHostEnvironment = webHostEnvironment ?? throw new ArgumentNullException ( nameof ( webHostEnvironment ) ) ;
45
49
_environment = environment ?? throw new ArgumentNullException ( nameof ( environment ) ) ;
46
-
47
50
_configuration = configuration as IConfigurationRoot ?? throw new ArgumentNullException ( nameof ( configuration ) ) ;
51
+ _languageWorkerChannelManager = languageWorkerChannelManager ?? throw new ArgumentNullException ( nameof ( languageWorkerChannelManager ) ) ;
48
52
}
49
53
50
54
public static IChangeToken ChangeToken => _standbyChangeToken ;
@@ -66,8 +70,8 @@ public async Task SpecializeHostCoreAsync()
66
70
// Trigger a configuration reload to pick up all current settings
67
71
_configuration ? . Reload ( ) ;
68
72
73
+ await _languageWorkerChannelManager . SpecializeAsync ( ) ;
69
74
NotifyChange ( ) ;
70
-
71
75
await _scriptHostManager . RestartHostAsync ( ) ;
72
76
await _scriptHostManager . DelayUntilHostReady ( ) ;
73
77
}
0 commit comments