@@ -109,23 +109,7 @@ public async Task InitializeAsync()
109
109
{
110
110
try
111
111
{
112
- string scriptPath = _options . CurrentValue . ScriptPath ;
113
- _logger . LogInformation ( $ "Creating StandbyMode placeholder function directory ({ scriptPath } )") ;
114
-
115
- await FileUtility . DeleteDirectoryAsync ( scriptPath , true ) ;
116
- FileUtility . EnsureDirectoryExists ( scriptPath ) ;
117
-
118
- string content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.host.json") ;
119
- File . WriteAllText ( Path . Combine ( scriptPath , "host.json" ) , content ) ;
120
-
121
- string functionPath = Path . Combine ( scriptPath , WarmUpConstants . FunctionName ) ;
122
- Directory . CreateDirectory ( functionPath ) ;
123
- content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .function.json") ;
124
- File . WriteAllText ( Path . Combine ( functionPath , "function.json" ) , content ) ;
125
- content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .run.csx") ;
126
- File . WriteAllText ( Path . Combine ( functionPath , "run.csx" ) , content ) ;
127
-
128
- _logger . LogInformation ( $ "StandbyMode placeholder function directory created") ;
112
+ await CreateStandbyWarmupFunctions ( ) ;
129
113
130
114
// start a background timer to identify when specialization happens
131
115
// specialization usually happens via an http request (e.g. scale controller
@@ -140,6 +124,27 @@ public async Task InitializeAsync()
140
124
}
141
125
}
142
126
127
+ private async Task CreateStandbyWarmupFunctions ( )
128
+ {
129
+ string scriptPath = _options . CurrentValue . ScriptPath ;
130
+ _logger . LogInformation ( $ "Creating StandbyMode placeholder function directory ({ scriptPath } )") ;
131
+
132
+ await FileUtility . DeleteDirectoryAsync ( scriptPath , true ) ;
133
+ FileUtility . EnsureDirectoryExists ( scriptPath ) ;
134
+
135
+ string content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.host.json") ;
136
+ File . WriteAllText ( Path . Combine ( scriptPath , "host.json" ) , content ) ;
137
+
138
+ string functionPath = Path . Combine ( scriptPath , WarmUpConstants . FunctionName ) ;
139
+ Directory . CreateDirectory ( functionPath ) ;
140
+ content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .function.json") ;
141
+ File . WriteAllText ( Path . Combine ( functionPath , "function.json" ) , content ) ;
142
+ content = FileUtility . ReadResourceString ( $ "{ ScriptConstants . ResourcePath } .Functions.{ WarmUpConstants . FunctionName } .run.csx") ;
143
+ File . WriteAllText ( Path . Combine ( functionPath , "run.csx" ) , content ) ;
144
+
145
+ _logger . LogInformation ( $ "StandbyMode placeholder function directory created") ;
146
+ }
147
+
143
148
private void OnSpecializationTimerTick ( object state )
144
149
{
145
150
if ( ! _webHostEnvironment . InStandbyMode && _environment . IsContainerReady ( ) )
0 commit comments