@@ -114,9 +114,11 @@ internal void EnsureInitialized(WebHostSettings settings)
114114 if ( ! WebScriptHostManager . InStandbyMode )
115115 {
116116 // standby mode can only change from true to false
117- // When standby mode changes, we reset all instances
117+ // when standby mode changes, we reset all instances
118118 if ( _activeHostManager == null )
119119 {
120+ _settingsManager . Reset ( ) ;
121+
120122 _activeScriptHostConfig = CreateScriptHostConfiguration ( settings ) ;
121123 _activeHostManager = new WebScriptHostManager ( _activeScriptHostConfig , _secretManagerFactory , _eventManager , _settingsManager , settings ) ;
122124 _activeReceiverManager = new WebHookReceiverManager ( _activeHostManager . SecretManager ) ;
@@ -139,15 +141,15 @@ internal void EnsureInitialized(WebHostSettings settings)
139141 _standbyScriptHostConfig = null ;
140142 _standbyHostManager = null ;
141143 _standbyReceiverManager = null ;
142- _settingsManager . Reset ( ) ;
143144 }
144145 }
145146 else
146147 {
147148 if ( _standbyHostManager == null )
148149 {
149- _standbyScriptHostConfig = CreateScriptHostConfiguration ( settings , true ) ;
150- _standbyHostManager = new WebScriptHostManager ( _standbyScriptHostConfig , _secretManagerFactory , _eventManager , _settingsManager , settings ) ;
150+ var standbySetings = CreateStandbySettings ( settings ) ;
151+ _standbyScriptHostConfig = CreateScriptHostConfiguration ( standbySetings , true ) ;
152+ _standbyHostManager = new WebScriptHostManager ( _standbyScriptHostConfig , _secretManagerFactory , _eventManager , _settingsManager , standbySetings ) ;
151153 _standbyReceiverManager = new WebHookReceiverManager ( _standbyHostManager . SecretManager ) ;
152154
153155 InitializeFileSystem ( ) ;
@@ -156,6 +158,26 @@ internal void EnsureInitialized(WebHostSettings settings)
156158 }
157159 }
158160
161+ internal static WebHostSettings CreateStandbySettings ( WebHostSettings settings )
162+ {
163+ // we need to create a new copy of the settings to avoid modifying
164+ // the global settings
165+ // important that we use paths that are different than the configured paths
166+ // to ensure that placeholder files are isolated
167+ string tempRoot = Path . GetTempPath ( ) ;
168+ var standbySettings = new WebHostSettings
169+ {
170+ LogPath = Path . Combine ( tempRoot , @"Functions\Standby\Logs" ) ,
171+ ScriptPath = Path . Combine ( tempRoot , @"Functions\Standby\WWWRoot" ) ,
172+ SecretsPath = Path . Combine ( tempRoot , @"Functions\Standby\Secrets" ) ,
173+ LoggerFactoryBuilder = settings . LoggerFactoryBuilder ,
174+ TraceWriter = settings . TraceWriter ,
175+ IsSelfHost = settings . IsSelfHost
176+ } ;
177+
178+ return standbySettings ;
179+ }
180+
159181 internal static ScriptHostConfiguration CreateScriptHostConfiguration ( WebHostSettings settings , bool inStandbyMode = false )
160182 {
161183 var scriptHostConfig = new ScriptHostConfiguration
@@ -170,7 +192,6 @@ internal static ScriptHostConfiguration CreateScriptHostConfiguration(WebHostSet
170192
171193 if ( inStandbyMode )
172194 {
173- scriptHostConfig . RootScriptPath = Path . Combine ( Path . GetTempPath ( ) , "Functions" , "Standby" ) ;
174195 scriptHostConfig . FileLoggingMode = FileLoggingMode . DebugOnly ;
175196 scriptHostConfig . HostConfig . StorageConnectionString = null ;
176197 scriptHostConfig . HostConfig . DashboardConnectionString = null ;
0 commit comments