diff --git a/package.json b/package.json index 504d8b1446fc715a971bbd968cbc3f85b0480749..a47f5ed064b31ab95053a135b976a29761a4dca6 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "json2csv": "^5.0.6", "jsonwebtoken": "^8.5.1", "jwt-decode": "^3.1.2", + "kill-port": "^1.6.1", "material-ui": "^0.20.2", "mongodb": "^3.6.4", "mongoose": "^5.11.15", diff --git a/src/components/Stepper/GlobalConfig.js b/src/components/Stepper/GlobalConfig.js index 7627e494dd1e7de2ff26d1b3946617b4b391a727..732f5fe945569231c8c99185faedd9af6c304a0d 100644 --- a/src/components/Stepper/GlobalConfig.js +++ b/src/components/Stepper/GlobalConfig.js @@ -110,13 +110,7 @@ export default function GlobalConfig() { [e.target.id]: newValue, }); }; - const handleCluster = (e) => { - setRunState({ - ...runState, - [e.target.name]: String(e.target.checked), - outdir: runState.cluster ? "remote" : path.dirname(runState.genome), - }); - }; + console.log(runState.remoteDir); console.log(value); diff --git a/src/components/Visualization/VisualizationFill.js b/src/components/Visualization/VisualizationFill.js index ecf2ac95a78121a7f4d64dd4c80b77463be11c0d..e595666aaf0ed3ce2d0bece435ae77b044d25e36 100644 --- a/src/components/Visualization/VisualizationFill.js +++ b/src/components/Visualization/VisualizationFill.js @@ -17,6 +17,8 @@ import Typography from "@material-ui/core/Typography"; import IconButton from "@material-ui/core/IconButton"; import Container from "@material-ui/core/Container"; +const kill = require("kill-port"); +const running = require("is-running"); const handler = require("serve-handler"); const electron = window.require("electron"); const { shell } = window.require("electron"); @@ -351,32 +353,37 @@ export default function VisualizationFill() { console.log(result); const handleServe = () => { - try { - const server = http.createServer(async (request, response) => { - await handler(request, response, { - public: user.user.jbPath, - }); + const server = http.createServer(async (request, response) => { + handler(request, response, { + public: user.user.jbPath, }); - console.log(user.user.jbPath); - server.listen(user.user.port[0], () => {}); - } catch (err) { - portastic - .find({ - min: 30000, - max: 35000, - retrieve: 1, - }) - .then(function (port) { - const server = http.createServer(async (request, response) => { - await handler(request, response, { - public: user.user.jbPath, - }); - }); - server.listen(user.user.port[0], () => {}); - shell.openExternal(`http:///localhost:${port}`); - }); - } - shell.openExternal(`http:///localhost:${user.user.port[0]}`); + }); + + server.listen(user.user.port[0], () => { + console.log(server.listening); + + shell.openExternal(`http:///localhost:${user.user.port[0]}`); + }); + server.on("error", (err) => { + console.log(err); + }); + + // portastic + // .find({ + // min: 30000, + // max: 35000, + // retrieve: 1, + // }) + // .then(function (port) { + // const server = http.createServer(async (request, response) => { + // await handler(request, response, { + // public: user.user.jbPath, + // }); + // }); + // server.listen(user.user.port[0], () => {}); + // shell.openExternal(`http:///localhost:${port}`); + // }); + // } }; return ( <Container maxWidth="lg" className={classes.container} gutterbottom> diff --git a/yarn.lock b/yarn.lock index 4f6b70bec4d4bfcfc1fef92ab458df51259960e1..51b2eaa15d9b2eb1939c93eb91f41498588a5af2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8753,6 +8753,11 @@ get-stream@^5.0.0, get-stream@^5.1.0: dependencies: pump "^3.0.0" +get-them-args@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/get-them-args/-/get-them-args-1.3.2.tgz#74a20ba8a4abece5ae199ad03f2bcc68fdfc9ba5" + integrity sha1-dKILqKSr7OWuGZrQPyvMaP38m6U= + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -11333,6 +11338,14 @@ keyv@^4.0.0: dependencies: json-buffer "3.0.1" +kill-port@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/kill-port/-/kill-port-1.6.1.tgz#560fe79484583bdf3a5e908557dae614447618aa" + integrity sha512-un0Y55cOM7JKGaLnGja28T38tDDop0AQ8N0KlAdyh+B1nmMoX8AnNmqPNZbS3mUMgiST51DCVqmbFT1gNJpVNw== + dependencies: + get-them-args "1.3.2" + shell-exec "1.0.2" + killable@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.1.tgz#4c8ce441187a061c7474fb87ca08e2a638194892" @@ -16604,6 +16617,11 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +shell-exec@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/shell-exec/-/shell-exec-1.0.2.tgz#2e9361b0fde1d73f476c4b6671fa17785f696756" + integrity sha512-jyVd+kU2X+mWKMmGhx4fpWbPsjvD53k9ivqetutVW/BQ+WIZoDoP4d8vUMGezV6saZsiNoW2f9GIhg9Dondohg== + shell-quote@1.7.2: version "1.7.2" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"