{"action":"created","comment":{"url":"https://api.github.com/repos/terascope/teraslice/pulls/comments/221403544","pull_request_review_id":160052154,"id":221403544,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTQwMzU0NA==","diff_hunk":"@@ -0,0 +1,163 @@\n+'use strict';\n+'use console';\n+\n+/* eslint-disable no-console */\n+/* eslint-disable no-await-in-loop */\n+\n+const fs = require('fs-extra');\n+const prompt = require('syncprompt');\n+const _ = require('lodash');\n+const reply = require('../../lib/reply')();\n+const display = require('../../lib/display')();\n+\n+module.exports = (cliConfig) => {\n+    const terasliceClient = require('teraslice-client-js')({\n+        host: cliConfig.cluster_url\n+    });\n+\n+    async function stop() {\n+        let waitCountStop = 0;\n+        const waitMaxStop = 10;\n+        let stopTimedOut = false;\n+        let exStopped = false;\n+        let response = '';\n+        while (!stopTimedOut) {\n+            if (waitCountStop >= waitMaxStop) {\n+                break;\n+            }\n+            try {\n+                response = await terasliceClient.ex.stop(cliConfig.deets.id);\n+                stopTimedOut = true;\n+                console.log(`> ex_id: ${cliConfig.deets.id} stopped`);\n+            } catch (err) {\n+                reply.error(`> Stopping ex_id had an error [${err.message}]`);\n+                if (err.message.indexOf(' no active execution context was found') > 0) {\n+                    stopTimedOut = true;\n+                } else {\n+                    stopTimedOut = false;\n+                }\n+            }\n+            await _.delay(() => {}, 500);\n+            waitCountStop += 1;\n+        }\n+        if (response.status === 'stopped') {\n+            exStopped = true;\n+        }\n+\n+        return exStopped;\n+    }\n+\n+    async function save() {\n+        return list(true);\n+    }\n+\n+    async function status() {\n+        if (cliConfig.deets.id === undefined) {\n+            console.log('ex_id required for status');\n+        } else {\n+            await list();\n+        }\n+    }\n+    async function list(showInfo = true, showExIds = true) {\n+        const exIds = [];\n+        if (showInfo) {\n+            await displayInfo();\n+        }\n+\n+        for (const statusEx of cliConfig.statusList) {\n+            const exResult = await terasliceClient.ex.list(statusEx);\n+            if (exResult.length > 0) {\n+                _.each(exResult, (ex) => {\n+                    if (cliConfig.deets.id === undefined) {\n+                        exIds.push(ex);\n+                    } else if (cliConfig.deets.id === ex.ex_id) {\n+                        exIds.push(ex);\n+                    }\n+                });\n+            }\n+        }\n+\n+        if (exIds.length > 0) {\n+            if (showExIds) {\n+                await displayExIds(exIds);\n+            }\n+            if (save) {\n+                await fs.writeJson(cliConfig.state_file, exIds, { spaces: 4 });\n+            }\n+        }\n+\n+        return exIds;\n+    }\n+\n+    async function displayExIds(exIds, file = false) {\n+        const headerExIds = await setHeaderDefaults(file);\n+        let exParsed = '';\n+        if (cliConfig.output_style === 'txt') {\n+            exParsed = await parseExResponseTxt(exIds, file);\n+        } else {\n+            exParsed = await parseExResponse(exIds, file);\n+        }\n+        await display.display(headerExIds, exParsed, cliConfig.output_style);\n+    }\n+\n+    async function displayInfo() {\n+        const header = ['host', 'state_file']\n+        const rows = [];\n+        if (cliConfig.output_style === 'txt') {\n+            const row = {};\n+            row.host = cliConfig.hostname;\n+            row.state_file = cliConfig.state_file;\n+            rows.push(row);\n+        } else {\n+            const row = [];\n+            row.push(cliConfig.hostname);\n+            row.push(cliConfig.state_file);\n+            rows.push(row);\n+        }\n+\n+        await display.display(header, rows, cliConfig.output_style);\n+    }\n+    async function parseExResponseTxt(response, file = false) {\n+        return response;\n+    }\n+    async function parseExResponse(response, file = false) {\n+        const rows = [];\n+\n+        _.forEach(response, (value, node) => {\n+            const row = [];\n+            row.push(response[node].name);\n+            row.push(response[node].lifecycle);\n+            row.push(response[node].slicers);\n+            row.push(response[node].workers);\n+            if (!file) {\n+                row.push(response[node]._status);\n+            }\n+\n+            row.push(response[node].ex_id);\n+            row.push(response[node].job_id);\n+            row.push(response[node]._created);\n+            row.push(response[node]._updated);\n+            rows.push(row);\n+        });\n+        return rows;\n+    }\n+\n+    async function setHeaderDefaults(file = false) {\n+        let defaults = [];\n+        if (file) {\n+            defaults = ['name', 'lifecycle', 'slicers', 'workers', 'ex_id', 'job_id', '_created', '_updated'];\n+        } else {\n+            defaults = ['name', 'lifecycle', 'slicers', 'workers', '_status', 'ex_id', 'job_id', '_created', '_updated'];\n+        }\n+        return defaults;\n+    }\n+","path":"packages/teraslice-cli/cmds/ex/lib/index.js","position":154,"original_position":154,"commit_id":"b3ef953c91af17de4e4c41189f9093cfd1b606e4","original_commit_id":"b3ef953c91af17de4e4c41189f9093cfd1b606e4","user":{"login":"codacy-bot","id":19940114,"node_id":"MDQ6VXNlcjE5OTQwMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://app.codacy.com/assets/images/favicon.png) Issue found: [More than 2 blank lines not allowed. (no-multiple-empty-lines)](https://app.codacy.com/app/terascope/teraslice/pullRequest?prid=2270248)","created_at":"2018-09-28T23:35:44Z","updated_at":"2018-09-28T23:35:45Z","html_url":"https://github.com/terascope/teraslice/pull/843#discussion_r221403544","pull_request_url":"https://api.github.com/repos/terascope/teraslice/pulls/843","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/terascope/teraslice/pulls/comments/221403544"},"html":{"href":"https://github.com/terascope/teraslice/pull/843#discussion_r221403544"},"pull_request":{"href":"https://api.github.com/repos/terascope/teraslice/pulls/843"}}},"pull_request":{"url":"https://api.github.com/repos/terascope/teraslice/pulls/843","id":219021774,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5MDIxNzc0","html_url":"https://github.com/terascope/teraslice/pull/843","diff_url":"https://github.com/terascope/teraslice/pull/843.diff","patch_url":"https://github.com/terascope/teraslice/pull/843.patch","issue_url":"https://api.github.com/repos/terascope/teraslice/issues/843","number":843,"state":"open","locked":false,"title":"Expand teraslice cli functionality","user":{"login":"jeffmontagna","id":7225926,"node_id":"MDQ6VXNlcjcyMjU5MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/7225926?v=4","gravatar_id":"","url":"https://api.github.com/users/jeffmontagna","html_url":"https://github.com/jeffmontagna","followers_url":"https://api.github.com/users/jeffmontagna/followers","following_url":"https://api.github.com/users/jeffmontagna/following{/other_user}","gists_url":"https://api.github.com/users/jeffmontagna/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmontagna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmontagna/subscriptions","organizations_url":"https://api.github.com/users/jeffmontagna/orgs","repos_url":"https://api.github.com/users/jeffmontagna/repos","events_url":"https://api.github.com/users/jeffmontagna/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmontagna/received_events","type":"User","site_admin":false},"body":"These changes expands the functionality of the cli tool to interface with teraslice clusters without the needing the job files\r\n- Sub-commands are split out into individual files\r\n- Config file has been added and is stored in `~/.teraslice/earl.yaml\r\n- Clusters can be identified with an alias, which is saved in the config file \r\n- `cjob` commands right now only work with ids specified on the command line or running on the cluster.\r\n- Plan on renaming command from tjm to earl.","created_at":"2018-09-28T16:27:46Z","updated_at":"2018-09-28T23:35:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"862e457c45d061e407f2691d10bcf2ec4a3bbe40","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/terascope/teraslice/pulls/843/commits","review_comments_url":"https://api.github.com/repos/terascope/teraslice/pulls/843/comments","review_comment_url":"https://api.github.com/repos/terascope/teraslice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/terascope/teraslice/issues/843/comments","statuses_url":"https://api.github.com/repos/terascope/teraslice/statuses/b3ef953c91af17de4e4c41189f9093cfd1b606e4","head":{"label":"jeffmontagna:expand-teraslice-cli-functionality","ref":"expand-teraslice-cli-functionality","sha":"b3ef953c91af17de4e4c41189f9093cfd1b606e4","user":{"login":"jeffmontagna","id":7225926,"node_id":"MDQ6VXNlcjcyMjU5MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/7225926?v=4","gravatar_id":"","url":"https://api.github.com/users/jeffmontagna","html_url":"https://github.com/jeffmontagna","followers_url":"https://api.github.com/users/jeffmontagna/followers","following_url":"https://api.github.com/users/jeffmontagna/following{/other_user}","gists_url":"https://api.github.com/users/jeffmontagna/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmontagna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmontagna/subscriptions","organizations_url":"https://api.github.com/users/jeffmontagna/orgs","repos_url":"https://api.github.com/users/jeffmontagna/repos","events_url":"https://api.github.com/users/jeffmontagna/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmontagna/received_events","type":"User","site_admin":false},"repo":{"id":100390806,"node_id":"MDEwOlJlcG9zaXRvcnkxMDAzOTA4MDY=","name":"teraslice","full_name":"jeffmontagna/teraslice","private":false,"owner":{"login":"jeffmontagna","id":7225926,"node_id":"MDQ6VXNlcjcyMjU5MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/7225926?v=4","gravatar_id":"","url":"https://api.github.com/users/jeffmontagna","html_url":"https://github.com/jeffmontagna","followers_url":"https://api.github.com/users/jeffmontagna/followers","following_url":"https://api.github.com/users/jeffmontagna/following{/other_user}","gists_url":"https://api.github.com/users/jeffmontagna/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffmontagna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffmontagna/subscriptions","organizations_url":"https://api.github.com/users/jeffmontagna/orgs","repos_url":"https://api.github.com/users/jeffmontagna/repos","events_url":"https://api.github.com/users/jeffmontagna/events{/privacy}","received_events_url":"https://api.github.com/users/jeffmontagna/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jeffmontagna/teraslice","description":"Distributed computing platform for processing JSON data stored in Elasticsearch","fork":true,"url":"https://api.github.com/repos/jeffmontagna/teraslice","forks_url":"https://api.github.com/repos/jeffmontagna/teraslice/forks","keys_url":"https://api.github.com/repos/jeffmontagna/teraslice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeffmontagna/teraslice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeffmontagna/teraslice/teams","hooks_url":"https://api.github.com/repos/jeffmontagna/teraslice/hooks","issue_events_url":"https://api.github.com/repos/jeffmontagna/teraslice/issues/events{/number}","events_url":"https://api.github.com/repos/jeffmontagna/teraslice/events","assignees_url":"https://api.github.com/repos/jeffmontagna/teraslice/assignees{/user}","branches_url":"https://api.github.com/repos/jeffmontagna/teraslice/branches{/branch}","tags_url":"https://api.github.com/repos/jeffmontagna/teraslice/tags","blobs_url":"https://api.github.com/repos/jeffmontagna/teraslice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeffmontagna/teraslice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeffmontagna/teraslice/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeffmontagna/teraslice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeffmontagna/teraslice/statuses/{sha}","languages_url":"https://api.github.com/repos/jeffmontagna/teraslice/languages","stargazers_url":"https://api.github.com/repos/jeffmontagna/teraslice/stargazers","contributors_url":"https://api.github.com/repos/jeffmontagna/teraslice/contributors","subscribers_url":"https://api.github.com/repos/jeffmontagna/teraslice/subscribers","subscription_url":"https://api.github.com/repos/jeffmontagna/teraslice/subscription","commits_url":"https://api.github.com/repos/jeffmontagna/teraslice/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeffmontagna/teraslice/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeffmontagna/teraslice/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeffmontagna/teraslice/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeffmontagna/teraslice/contents/{+path}","compare_url":"https://api.github.com/repos/jeffmontagna/teraslice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeffmontagna/teraslice/merges","archive_url":"https://api.github.com/repos/jeffmontagna/teraslice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeffmontagna/teraslice/downloads","issues_url":"https://api.github.com/repos/jeffmontagna/teraslice/issues{/number}","pulls_url":"https://api.github.com/repos/jeffmontagna/teraslice/pulls{/number}","milestones_url":"https://api.github.com/repos/jeffmontagna/teraslice/milestones{/number}","notifications_url":"https://api.github.com/repos/jeffmontagna/teraslice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeffmontagna/teraslice/labels{/name}","releases_url":"https://api.github.com/repos/jeffmontagna/teraslice/releases{/id}","deployments_url":"https://api.github.com/repos/jeffmontagna/teraslice/deployments","created_at":"2017-08-15T15:20:49Z","updated_at":"2018-09-05T17:57:28Z","pushed_at":"2018-09-28T21:39:10Z","git_url":"git://github.com/jeffmontagna/teraslice.git","ssh_url":"git@github.com:jeffmontagna/teraslice.git","clone_url":"https://github.com/jeffmontagna/teraslice.git","svn_url":"https://github.com/jeffmontagna/teraslice","homepage":"","size":4180,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"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":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"terascope:master","ref":"master","sha":"540dccb60ce7e0b3faade3576f3f18c4d6fe5994","user":{"login":"terascope","id":11777882,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzc3ODgy","avatar_url":"https://avatars0.githubusercontent.com/u/11777882?v=4","gravatar_id":"","url":"https://api.github.com/users/terascope","html_url":"https://github.com/terascope","followers_url":"https://api.github.com/users/terascope/followers","following_url":"https://api.github.com/users/terascope/following{/other_user}","gists_url":"https://api.github.com/users/terascope/gists{/gist_id}","starred_url":"https://api.github.com/users/terascope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terascope/subscriptions","organizations_url":"https://api.github.com/users/terascope/orgs","repos_url":"https://api.github.com/users/terascope/repos","events_url":"https://api.github.com/users/terascope/events{/privacy}","received_events_url":"https://api.github.com/users/terascope/received_events","type":"Organization","site_admin":false},"repo":{"id":39474293,"node_id":"MDEwOlJlcG9zaXRvcnkzOTQ3NDI5Mw==","name":"teraslice","full_name":"terascope/teraslice","private":false,"owner":{"login":"terascope","id":11777882,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzc3ODgy","avatar_url":"https://avatars0.githubusercontent.com/u/11777882?v=4","gravatar_id":"","url":"https://api.github.com/users/terascope","html_url":"https://github.com/terascope","followers_url":"https://api.github.com/users/terascope/followers","following_url":"https://api.github.com/users/terascope/following{/other_user}","gists_url":"https://api.github.com/users/terascope/gists{/gist_id}","starred_url":"https://api.github.com/users/terascope/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terascope/subscriptions","organizations_url":"https://api.github.com/users/terascope/orgs","repos_url":"https://api.github.com/users/terascope/repos","events_url":"https://api.github.com/users/terascope/events{/privacy}","received_events_url":"https://api.github.com/users/terascope/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/terascope/teraslice","description":"Distributed computing platform for processing JSON data","fork":false,"url":"https://api.github.com/repos/terascope/teraslice","forks_url":"https://api.github.com/repos/terascope/teraslice/forks","keys_url":"https://api.github.com/repos/terascope/teraslice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/terascope/teraslice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/terascope/teraslice/teams","hooks_url":"https://api.github.com/repos/terascope/teraslice/hooks","issue_events_url":"https://api.github.com/repos/terascope/teraslice/issues/events{/number}","events_url":"https://api.github.com/repos/terascope/teraslice/events","assignees_url":"https://api.github.com/repos/terascope/teraslice/assignees{/user}","branches_url":"https://api.github.com/repos/terascope/teraslice/branches{/branch}","tags_url":"https://api.github.com/repos/terascope/teraslice/tags","blobs_url":"https://api.github.com/repos/terascope/teraslice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/terascope/teraslice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/terascope/teraslice/git/refs{/sha}","trees_url":"https://api.github.com/repos/terascope/teraslice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/terascope/teraslice/statuses/{sha}","languages_url":"https://api.github.com/repos/terascope/teraslice/languages","stargazers_url":"https://api.github.com/repos/terascope/teraslice/stargazers","contributors_url":"https://api.github.com/repos/terascope/teraslice/contributors","subscribers_url":"https://api.github.com/repos/terascope/teraslice/subscribers","subscription_url":"https://api.github.com/repos/terascope/teraslice/subscription","commits_url":"https://api.github.com/repos/terascope/teraslice/commits{/sha}","git_commits_url":"https://api.github.com/repos/terascope/teraslice/git/commits{/sha}","comments_url":"https://api.github.com/repos/terascope/teraslice/comments{/number}","issue_comment_url":"https://api.github.com/repos/terascope/teraslice/issues/comments{/number}","contents_url":"https://api.github.com/repos/terascope/teraslice/contents/{+path}","compare_url":"https://api.github.com/repos/terascope/teraslice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/terascope/teraslice/merges","archive_url":"https://api.github.com/repos/terascope/teraslice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/terascope/teraslice/downloads","issues_url":"https://api.github.com/repos/terascope/teraslice/issues{/number}","pulls_url":"https://api.github.com/repos/terascope/teraslice/pulls{/number}","milestones_url":"https://api.github.com/repos/terascope/teraslice/milestones{/number}","notifications_url":"https://api.github.com/repos/terascope/teraslice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/terascope/teraslice/labels{/name}","releases_url":"https://api.github.com/repos/terascope/teraslice/releases{/id}","deployments_url":"https://api.github.com/repos/terascope/teraslice/deployments","created_at":"2015-07-21T23:09:13Z","updated_at":"2018-09-26T20:39:36Z","pushed_at":"2018-09-28T22:51:44Z","git_url":"git://github.com/terascope/teraslice.git","ssh_url":"git@github.com:terascope/teraslice.git","clone_url":"https://github.com/terascope/teraslice.git","svn_url":"https://github.com/terascope/teraslice","homepage":"","size":4180,"stargazers_count":23,"watchers_count":23,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"archived":false,"open_issues_count":50,"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":11,"open_issues":50,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/terascope/teraslice/pulls/843"},"html":{"href":"https://github.com/terascope/teraslice/pull/843"},"issue":{"href":"https://api.github.com/repos/terascope/teraslice/issues/843"},"comments":{"href":"https://api.github.com/repos/terascope/teraslice/issues/843/comments"},"review_comments":{"href":"https://api.github.com/repos/terascope/teraslice/pulls/843/comments"},"review_comment":{"href":"https://api.github.com/repos/terascope/teraslice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/terascope/teraslice/pulls/843/commits"},"statuses":{"href":"https://api.github.com/repos/terascope/teraslice/statuses/b3ef953c91af17de4e4c41189f9093cfd1b606e4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"codacy-bot"}}