{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/comments/300627195","pull_request_review_id":258331475,"id":300627195,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMwMDYyNzE5NQ==","diff_hunk":"@@ -143,78 +216,279 @@ func (l *Lightning) Stop() {\n \tl.shutdown()\n }\n \n+func writeJSONError(w http.ResponseWriter, code int, prefix string, err error) {\n+\ttype errorResponse struct {\n+\t\tError string `json:\"error\"`\n+\t}\n+\n+\tw.WriteHeader(code)\n+\n+\tif err != nil {\n+\t\tprefix += \": \" + err.Error()\n+\t}\n+\tjson.NewEncoder(w).Encode(errorResponse{Error: prefix})\n+}\n+\n+func parseTaskID(req *http.Request) (int64, string, error) {\n+\tpath := strings.TrimPrefix(req.URL.Path, \"/\")\n+\ttaskIDString := path\n+\tverb := \"\"\n+\tif i := strings.IndexByte(path, '/'); i >= 0 {\n+\t\ttaskIDString = path[:i]\n+\t\tverb = path[i+1:]\n+\t}\n+\n+\ttaskID, err := strconv.ParseInt(taskIDString, 10, 64)\n+\tif err != nil {\n+\t\treturn 0, \"\", err\n+\t}\n+\n+\treturn taskID, verb, nil\n+}\n+\n func (l *Lightning) handleTask(w http.ResponseWriter, req *http.Request) {\n \tw.Header().Set(\"Content-Type\", \"application/json\")\n \n+\tif l.taskCfgs == nil {\n+\t\twriteJSONError(w, http.StatusNotImplemented, \"server-mode not enabled\", nil)","path":"lightning/lightning.go","position":238,"original_position":238,"commit_id":"6ce4812a6012420a84cfaf438c82931929a16a7c","original_commit_id":"6ce4812a6012420a84cfaf438c82931929a16a7c","user":{"login":"kennytm","id":103023,"node_id":"MDQ6VXNlcjEwMzAyMw==","avatar_url":"https://avatars1.githubusercontent.com/u/103023?v=4","gravatar_id":"","url":"https://api.github.com/users/kennytm","html_url":"https://github.com/kennytm","followers_url":"https://api.github.com/users/kennytm/followers","following_url":"https://api.github.com/users/kennytm/following{/other_user}","gists_url":"https://api.github.com/users/kennytm/gists{/gist_id}","starred_url":"https://api.github.com/users/kennytm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennytm/subscriptions","organizations_url":"https://api.github.com/users/kennytm/orgs","repos_url":"https://api.github.com/users/kennytm/repos","events_url":"https://api.github.com/users/kennytm/events{/privacy}","received_events_url":"https://api.github.com/users/kennytm/received_events","type":"User","site_admin":false},"body":"It's right, `l.taskCfgs` is not nil only if `--server-mode` is enabled. Added comments to explain.","created_at":"2019-07-05T10:18:28Z","updated_at":"2019-07-05T10:18:28Z","html_url":"https://github.com/pingcap/tidb-lightning/pull/199#discussion_r300627195","pull_request_url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/comments/300627195"},"html":{"href":"https://github.com/pingcap/tidb-lightning/pull/199#discussion_r300627195"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199"}},"in_reply_to_id":300625125},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199","id":288653302,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjg4NjUzMzAy","html_url":"https://github.com/pingcap/tidb-lightning/pull/199","diff_url":"https://github.com/pingcap/tidb-lightning/pull/199.diff","patch_url":"https://github.com/pingcap/tidb-lightning/pull/199.patch","issue_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues/199","number":199,"state":"open","locked":false,"title":"Introduce a basic web interface","user":{"login":"kennytm","id":103023,"node_id":"MDQ6VXNlcjEwMzAyMw==","avatar_url":"https://avatars1.githubusercontent.com/u/103023?v=4","gravatar_id":"","url":"https://api.github.com/users/kennytm","html_url":"https://github.com/kennytm","followers_url":"https://api.github.com/users/kennytm/followers","following_url":"https://api.github.com/users/kennytm/following{/other_user}","gists_url":"https://api.github.com/users/kennytm/gists{/gist_id}","starred_url":"https://api.github.com/users/kennytm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennytm/subscriptions","organizations_url":"https://api.github.com/users/kennytm/orgs","repos_url":"https://api.github.com/users/kennytm/repos","events_url":"https://api.github.com/users/kennytm/events{/privacy}","received_events_url":"https://api.github.com/users/kennytm/received_events","type":"User","site_admin":false},"body":"<!--\r\nThank you for contributing to TiDB-Lightning! Please read the [CONTRIBUTING](https://github.com/pingcap/tidb-lightning/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.\r\n-->\r\n\r\n### What problem does this PR solve? <!--add issue link with summary if exists-->\r\n\r\nIntroduce a web interface for viewing the current task progress and perform some task management in server mode (submit task, cancel task, pause and resume, etc).\r\n\r\n### What is changed and how it works?\r\n\r\n* The web interface is a Single Page Application written using React with Material-UI. \r\n* It communicates with Lightning via simple HTTP API. Updating is done by regular refreshing.\r\n* The entire checkpoint of the current task is cloned for the web interface to view.\r\n* (Added \"pause\"/\"resume\" and various task management APIs to make the web interface easier to demonstrate)\r\n\r\n### Check List <!--REMOVE the items that are not applicable-->\r\n\r\nTests <!-- At least one of them must be included. -->\r\n\r\n - Unit test\r\n - Integration test\r\n - Manual test (add detailed scripts or steps below)\r\n    * Manually execute the tasks and observe the change in the web interface\r\n\r\nSide effects\r\n\r\n - Possible performance regression\r\n - Increased code complexity\r\n\r\nRelated changes\r\n\r\n - Need to update the documentation\r\n - Need to update the `tidb-ansible` repository\r\n - Need to be included in the release note","created_at":"2019-06-16T21:28:21Z","updated_at":"2019-07-05T10:18:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"242262a324bc01af9438071eee63a0cf29d1471b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1184362853,"node_id":"MDU6TGFiZWwxMTg0MzYyODUz","url":"https://api.github.com/repos/pingcap/tidb-lightning/labels/Should%20Update%20Ansible","name":"Should Update Ansible","color":"52dd59","default":false},{"id":1150280303,"node_id":"MDU6TGFiZWwxMTUwMjgwMzAz","url":"https://api.github.com/repos/pingcap/tidb-lightning/labels/Should%20Update%20Docs","name":"Should Update Docs","color":"afffd6","default":false},{"id":1159858351,"node_id":"MDU6TGFiZWwxMTU5ODU4MzUx","url":"https://api.github.com/repos/pingcap/tidb-lightning/labels/priority/important","name":"priority/important","color":"ff342b","default":false},{"id":1135419451,"node_id":"MDU6TGFiZWwxMTM1NDE5NDUx","url":"https://api.github.com/repos/pingcap/tidb-lightning/labels/status/LGT1","name":"status/LGT1","color":"d4c5f9","default":false},{"id":1159860071,"node_id":"MDU6TGFiZWwxMTU5ODYwMDcx","url":"https://api.github.com/repos/pingcap/tidb-lightning/labels/type/feature","name":"type/feature","color":"f2dc8c","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues/199/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb-lightning/statuses/6ce4812a6012420a84cfaf438c82931929a16a7c","head":{"label":"pingcap:kennytm/web-interface-2","ref":"kennytm/web-interface-2","sha":"6ce4812a6012420a84cfaf438c82931929a16a7c","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":111641659,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE2NDE2NTk=","name":"tidb-lightning","full_name":"pingcap/tidb-lightning","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/tidb-lightning","description":"A high-speed data import tool for TiDB","fork":false,"url":"https://api.github.com/repos/pingcap/tidb-lightning","forks_url":"https://api.github.com/repos/pingcap/tidb-lightning/forks","keys_url":"https://api.github.com/repos/pingcap/tidb-lightning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb-lightning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb-lightning/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb-lightning/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb-lightning/events","assignees_url":"https://api.github.com/repos/pingcap/tidb-lightning/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb-lightning/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb-lightning/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb-lightning/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb-lightning/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb-lightning/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb-lightning/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb-lightning/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb-lightning/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb-lightning/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb-lightning/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb-lightning/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb-lightning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb-lightning/merges","archive_url":"https://api.github.com/repos/pingcap/tidb-lightning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb-lightning/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb-lightning/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb-lightning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb-lightning/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb-lightning/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tidb-lightning/deployments","created_at":"2017-11-22T05:48:41Z","updated_at":"2019-07-03T07:25:48Z","pushed_at":"2019-07-04T20:19:49Z","git_url":"git://github.com/pingcap/tidb-lightning.git","ssh_url":"git@github.com:pingcap/tidb-lightning.git","clone_url":"https://github.com/pingcap/tidb-lightning.git","svn_url":"https://github.com/pingcap/tidb-lightning","homepage":null,"size":9755,"stargazers_count":87,"watchers_count":87,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17,"open_issues":12,"watchers":87,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"9d55221952623027c399a67e06581f06ed8242e9","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":111641659,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE2NDE2NTk=","name":"tidb-lightning","full_name":"pingcap/tidb-lightning","private":false,"owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pingcap/tidb-lightning","description":"A high-speed data import tool for TiDB","fork":false,"url":"https://api.github.com/repos/pingcap/tidb-lightning","forks_url":"https://api.github.com/repos/pingcap/tidb-lightning/forks","keys_url":"https://api.github.com/repos/pingcap/tidb-lightning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb-lightning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb-lightning/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb-lightning/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb-lightning/events","assignees_url":"https://api.github.com/repos/pingcap/tidb-lightning/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb-lightning/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb-lightning/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb-lightning/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb-lightning/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb-lightning/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb-lightning/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb-lightning/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb-lightning/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb-lightning/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb-lightning/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb-lightning/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb-lightning/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb-lightning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb-lightning/merges","archive_url":"https://api.github.com/repos/pingcap/tidb-lightning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb-lightning/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb-lightning/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb-lightning/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb-lightning/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb-lightning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb-lightning/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb-lightning/releases{/id}","deployments_url":"https://api.github.com/repos/pingcap/tidb-lightning/deployments","created_at":"2017-11-22T05:48:41Z","updated_at":"2019-07-03T07:25:48Z","pushed_at":"2019-07-04T20:19:49Z","git_url":"git://github.com/pingcap/tidb-lightning.git","ssh_url":"git@github.com:pingcap/tidb-lightning.git","clone_url":"https://github.com/pingcap/tidb-lightning.git","svn_url":"https://github.com/pingcap/tidb-lightning","homepage":null,"size":9755,"stargazers_count":87,"watchers_count":87,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":12,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":17,"open_issues":12,"watchers":87,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199"},"html":{"href":"https://github.com/pingcap/tidb-lightning/pull/199"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/issues/199"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/issues/199/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/pulls/199/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb-lightning/statuses/6ce4812a6012420a84cfaf438c82931929a16a7c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"kennytm"}}