@@ -118,14 +118,25 @@ private void OnFileChanged(FileSystemEventArgs e)
118
118
string changeDescription = string . Empty ;
119
119
string directory = GetRelativeDirectory ( e . FullPath , _scriptOptions . RootScriptPath ) ;
120
120
string fileName = Path . GetFileName ( e . Name ) ;
121
+ bool shutdown = false ;
121
122
122
123
if ( _scriptOptions . WatchDirectories . Contains ( directory ) )
123
124
{
124
125
changeDescription = "Watched directory" ;
125
126
}
126
127
else if ( string . Compare ( fileName , ScriptConstants . AppOfflineFileName , StringComparison . OrdinalIgnoreCase ) == 0 )
127
128
{
128
- OnOfflineFileChanged ( e ) ;
129
+ // app_offline.htm has changed
130
+ // when app_offline.htm is created, we trigger
131
+ // a shutdown so when the host starts back up it
132
+ // will be offline
133
+ // when app_offline.htm is deleted, we trigger
134
+ // a restart to bring the host back online
135
+ changeDescription = "File" ;
136
+ if ( File . Exists ( e . FullPath ) )
137
+ {
138
+ shutdown = true ;
139
+ }
129
140
}
130
141
else if ( string . Compare ( fileName , ScriptConstants . HostMetadataFileName , StringComparison . OrdinalIgnoreCase ) == 0 ||
131
142
string . Compare ( fileName , ScriptConstants . FunctionMetadataFileName , StringComparison . OrdinalIgnoreCase ) == 0 ||
@@ -142,7 +153,6 @@ private void OnFileChanged(FileSystemEventArgs e)
142
153
143
154
if ( ! string . IsNullOrEmpty ( changeDescription ) )
144
155
{
145
- bool shutdown = false ;
146
156
string fileExtension = Path . GetExtension ( fileName ) ;
147
157
if ( ! string . IsNullOrEmpty ( fileExtension ) && ScriptConstants . AssemblyFileTypes . Contains ( fileExtension , StringComparer . OrdinalIgnoreCase ) )
148
158
{
@@ -239,23 +249,6 @@ public void Dispose()
239
249
Dispose ( true ) ;
240
250
}
241
251
242
- private void OnOfflineFileChanged ( FileSystemEventArgs e )
243
- {
244
- if ( e . ChangeType == WatcherChangeTypes . Created )
245
- {
246
- // when app_offline.htm is created, trigger
247
- // a shutdown so when the host starts back up it
248
- // will be offline
249
- Shutdown ( ) ;
250
- }
251
- else if ( e . ChangeType == WatcherChangeTypes . Deleted )
252
- {
253
- // after deleting app_offline.htm trigger a reinitialization
254
- // to bring the host back online
255
- _scriptEnvironment . RestartHost ( ) ;
256
- }
257
- }
258
-
259
252
internal static async Task SetAppOfflineState ( string rootPath , bool offline )
260
253
{
261
254
string path = Path . Combine ( rootPath , ScriptConstants . AppOfflineFileName ) ;
0 commit comments