{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/azure-functions-host/pulls/comments/210768170","pull_request_review_id":147055414,"id":210768170,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMDc2ODE3MA==","diff_hunk":"@@ -233,5 +238,44 @@ public void Dispose()\n         {\n             Dispose(true);\n         }\n+\n+        private void OnOfflineFileChanged(FileSystemEventArgs e)\n+        {\n+            if (e.ChangeType == WatcherChangeTypes.Created)\n+            {\n+                // when app_offline.htm is created, trigger\n+                // a shutdown so when the host starts back up it\n+                // will be offline\n+                Shutdown();\n+            }\n+            else if (e.ChangeType == WatcherChangeTypes.Deleted)\n+            {\n+                // after deleting app_offline.htm trigger a reinitialization\n+                // to bring the host back online\n+                _scriptEnvironment.RestartHost();\n+            }\n+        }\n+\n+        internal static void SetAppOfflineState(string rootPath, bool offline)\n+        {\n+            string path = Path.Combine(rootPath, ScriptConstants.AppOfflineFileName);\n+            bool offlineFileExists = File.Exists(path);\n+\n+            if (offline && !offlineFileExists)\n+            {\n+                // create the app_offline.htm file in the root script directory\n+                string content = FileUtility.ReadResourceString($\"{ScriptConstants.ResourcePath}.{ScriptConstants.AppOfflineFileName}\");\n+                var bytes = Encoding.UTF8.GetBytes(content);\n+                using (var fs = File.Create(path))\n+                {\n+                    fs.Write(bytes, 0, bytes.Length);\n+                }","path":"src/WebJobs.Script.WebHost/FileMonitoringService.cs","position":54,"original_position":54,"commit_id":"73f76bdf9ae1520eee3850a65d8d28ce3ea61867","original_commit_id":"73f76bdf9ae1520eee3850a65d8d28ce3ea61867","user":{"login":"mathewc","id":1056548,"node_id":"MDQ6VXNlcjEwNTY1NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/1056548?v=4","gravatar_id":"","url":"https://api.github.com/users/mathewc","html_url":"https://github.com/mathewc","followers_url":"https://api.github.com/users/mathewc/followers","following_url":"https://api.github.com/users/mathewc/following{/other_user}","gists_url":"https://api.github.com/users/mathewc/gists{/gist_id}","starred_url":"https://api.github.com/users/mathewc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathewc/subscriptions","organizations_url":"https://api.github.com/users/mathewc/orgs","repos_url":"https://api.github.com/users/mathewc/repos","events_url":"https://api.github.com/users/mathewc/events{/privacy}","received_events_url":"https://api.github.com/users/mathewc/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2018-08-16T23:13:57Z","updated_at":"2018-08-16T23:13:57Z","html_url":"https://github.com/Azure/azure-functions-host/pull/3269#discussion_r210768170","pull_request_url":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-functions-host/pulls/comments/210768170"},"html":{"href":"https://github.com/Azure/azure-functions-host/pull/3269#discussion_r210768170"},"pull_request":{"href":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269"}},"in_reply_to_id":210739635},"pull_request":{"url":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269","id":208951520,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA4OTUxNTIw","html_url":"https://github.com/Azure/azure-functions-host/pull/3269","diff_url":"https://github.com/Azure/azure-functions-host/pull/3269.diff","patch_url":"https://github.com/Azure/azure-functions-host/pull/3269.patch","issue_url":"https://api.github.com/repos/Azure/azure-functions-host/issues/3269","number":3269,"state":"open","locked":false,"title":"App Offline support","user":{"login":"mathewc","id":1056548,"node_id":"MDQ6VXNlcjEwNTY1NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/1056548?v=4","gravatar_id":"","url":"https://api.github.com/users/mathewc","html_url":"https://github.com/mathewc","followers_url":"https://api.github.com/users/mathewc/followers","following_url":"https://api.github.com/users/mathewc/following{/other_user}","gists_url":"https://api.github.com/users/mathewc/gists{/gist_id}","starred_url":"https://api.github.com/users/mathewc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathewc/subscriptions","organizations_url":"https://api.github.com/users/mathewc/orgs","repos_url":"https://api.github.com/users/mathewc/repos","events_url":"https://api.github.com/users/mathewc/events{/privacy}","received_events_url":"https://api.github.com/users/mathewc/received_events","type":"User","site_admin":false},"body":"These changes are intended to address the following issues:\r\n\r\n- https://github.com/Azure/azure-functions-host/issues/2548\r\n- https://github.com/Azure/azure-functions-host/issues/2700\r\n- https://github.com/Azure/azure-functions-host/issues/1521\r\n\r\nThe portal extensions manager can then use the new API added here to install extensions w/o running into file locking issues:\r\n\r\n- Portal Extension PUTs \"offline\" to `admin/host/state` to take the host offline\r\n- Host receives this request, writes an app_offline.htm file to script root dir\r\n- All hosts are watching for creation/deletion of this offline file: \r\n  - When created (take offline) – web app is recycled, causing the app domain to unload. When the app restarts, it sees the offline file and skips all host startup/init. I.e. in offline mode, no assemblies are loaded from bin, and only our admin type APIs are available (no functions are running).\r\n  - When deleted (bring online) – if the host was offline and this file is deleted, it is brought back online and allowed to initialize normally\r\n- While offline, extension APIs can be called to install one or more extensions. The `admin/host/status` endpoint also returns “Offline” as the host status.\r\n- Once installs are done, app is brought back online via a PUT of value \"running\" to `admin/host/state`\r\n\r\nVS managed app_offline.htm files are therefore also supported. E.g. if app offline is enabled for a WebDeploy, the runtime will see the file added by VS and go offline, freeing any locked files.","created_at":"2018-08-16T18:51:51Z","updated_at":"2018-08-16T23:13:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b404342478afb427d6b746a9f25cdeab84f975b","assignee":null,"assignees":[],"requested_reviewers":[{"login":"soninaren","id":8119379,"node_id":"MDQ6VXNlcjgxMTkzNzk=","avatar_url":"https://avatars0.githubusercontent.com/u/8119379?v=4","gravatar_id":"","url":"https://api.github.com/users/soninaren","html_url":"https://github.com/soninaren","followers_url":"https://api.github.com/users/soninaren/followers","following_url":"https://api.github.com/users/soninaren/following{/other_user}","gists_url":"https://api.github.com/users/soninaren/gists{/gist_id}","starred_url":"https://api.github.com/users/soninaren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soninaren/subscriptions","organizations_url":"https://api.github.com/users/soninaren/orgs","repos_url":"https://api.github.com/users/soninaren/repos","events_url":"https://api.github.com/users/soninaren/events{/privacy}","received_events_url":"https://api.github.com/users/soninaren/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269/commits","review_comments_url":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269/comments","review_comment_url":"https://api.github.com/repos/Azure/azure-functions-host/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/azure-functions-host/issues/3269/comments","statuses_url":"https://api.github.com/repos/Azure/azure-functions-host/statuses/73f76bdf9ae1520eee3850a65d8d28ce3ea61867","head":{"label":"Azure:app-offline","ref":"app-offline","sha":"73f76bdf9ae1520eee3850a65d8d28ce3ea61867","user":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":42548553,"node_id":"MDEwOlJlcG9zaXRvcnk0MjU0ODU1Mw==","name":"azure-functions-host","full_name":"Azure/azure-functions-host","owner":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-functions-host","description":"The host/runtime that powers Azure Functions","fork":false,"url":"https://api.github.com/repos/Azure/azure-functions-host","forks_url":"https://api.github.com/repos/Azure/azure-functions-host/forks","keys_url":"https://api.github.com/repos/Azure/azure-functions-host/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-functions-host/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-functions-host/teams","hooks_url":"https://api.github.com/repos/Azure/azure-functions-host/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-functions-host/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-functions-host/events","assignees_url":"https://api.github.com/repos/Azure/azure-functions-host/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-functions-host/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-functions-host/tags","blobs_url":"https://api.github.com/repos/Azure/azure-functions-host/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-functions-host/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-functions-host/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-functions-host/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-functions-host/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-functions-host/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-functions-host/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-functions-host/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-functions-host/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-functions-host/subscription","commits_url":"https://api.github.com/repos/Azure/azure-functions-host/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-functions-host/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-functions-host/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-functions-host/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-functions-host/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-functions-host/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-functions-host/merges","archive_url":"https://api.github.com/repos/Azure/azure-functions-host/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-functions-host/downloads","issues_url":"https://api.github.com/repos/Azure/azure-functions-host/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-functions-host/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-functions-host/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-functions-host/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-functions-host/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-functions-host/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-functions-host/deployments","created_at":"2015-09-15T21:48:19Z","updated_at":"2018-08-16T23:00:18Z","pushed_at":"2018-08-16T23:06:31Z","git_url":"git://github.com/Azure/azure-functions-host.git","ssh_url":"git@github.com:Azure/azure-functions-host.git","clone_url":"https://github.com/Azure/azure-functions-host.git","svn_url":"https://github.com/Azure/azure-functions-host","homepage":"https://functions.azure.com","size":22286,"stargazers_count":881,"watchers_count":881,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":182,"mirror_url":null,"archived":false,"open_issues_count":631,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":182,"open_issues":631,"watchers":881,"default_branch":"dev"}},"base":{"label":"Azure:dev","ref":"dev","sha":"e8539fa1a56afa8d73259a78e0bb73a21ca045a3","user":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":42548553,"node_id":"MDEwOlJlcG9zaXRvcnk0MjU0ODU1Mw==","name":"azure-functions-host","full_name":"Azure/azure-functions-host","owner":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/azure-functions-host","description":"The host/runtime that powers Azure Functions","fork":false,"url":"https://api.github.com/repos/Azure/azure-functions-host","forks_url":"https://api.github.com/repos/Azure/azure-functions-host/forks","keys_url":"https://api.github.com/repos/Azure/azure-functions-host/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/azure-functions-host/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/azure-functions-host/teams","hooks_url":"https://api.github.com/repos/Azure/azure-functions-host/hooks","issue_events_url":"https://api.github.com/repos/Azure/azure-functions-host/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/azure-functions-host/events","assignees_url":"https://api.github.com/repos/Azure/azure-functions-host/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/azure-functions-host/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/azure-functions-host/tags","blobs_url":"https://api.github.com/repos/Azure/azure-functions-host/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/azure-functions-host/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/azure-functions-host/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/azure-functions-host/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/azure-functions-host/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/azure-functions-host/languages","stargazers_url":"https://api.github.com/repos/Azure/azure-functions-host/stargazers","contributors_url":"https://api.github.com/repos/Azure/azure-functions-host/contributors","subscribers_url":"https://api.github.com/repos/Azure/azure-functions-host/subscribers","subscription_url":"https://api.github.com/repos/Azure/azure-functions-host/subscription","commits_url":"https://api.github.com/repos/Azure/azure-functions-host/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/azure-functions-host/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/azure-functions-host/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/azure-functions-host/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/azure-functions-host/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/azure-functions-host/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/azure-functions-host/merges","archive_url":"https://api.github.com/repos/Azure/azure-functions-host/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/azure-functions-host/downloads","issues_url":"https://api.github.com/repos/Azure/azure-functions-host/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/azure-functions-host/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/azure-functions-host/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/azure-functions-host/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/azure-functions-host/labels{/name}","releases_url":"https://api.github.com/repos/Azure/azure-functions-host/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/azure-functions-host/deployments","created_at":"2015-09-15T21:48:19Z","updated_at":"2018-08-16T23:00:18Z","pushed_at":"2018-08-16T23:06:31Z","git_url":"git://github.com/Azure/azure-functions-host.git","ssh_url":"git@github.com:Azure/azure-functions-host.git","clone_url":"https://github.com/Azure/azure-functions-host.git","svn_url":"https://github.com/Azure/azure-functions-host","homepage":"https://functions.azure.com","size":22286,"stargazers_count":881,"watchers_count":881,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":182,"mirror_url":null,"archived":false,"open_issues_count":631,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":182,"open_issues":631,"watchers":881,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269"},"html":{"href":"https://github.com/Azure/azure-functions-host/pull/3269"},"issue":{"href":"https://api.github.com/repos/Azure/azure-functions-host/issues/3269"},"comments":{"href":"https://api.github.com/repos/Azure/azure-functions-host/issues/3269/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/azure-functions-host/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/azure-functions-host/pulls/3269/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/azure-functions-host/statuses/73f76bdf9ae1520eee3850a65d8d28ce3ea61867"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mathewc"}}