-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ui fixes + edit invocation screen + process wrapper poc script …
…(#209) * feat: added blog to loggedout navbar * feat: cli wrapper * chore: create model layer * feat: disable supabase env * feat: mock dialogs service selector * fix: remove collapse from config card * fix: request card design * fix: sidebar * feat: invocation editor * feat: add disable to sniffer selector * feat: invocation page * feat: request load data return promise * fix: types and remove console.log * feat: add invocation editor to routing * fix: not found return element and not string * fix: eslint rules * fix: send data from inputs to execute * fix: test * fix: husky
- Loading branch information
Showing
34 changed files
with
927 additions
and
685 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const { spawn } = require("child_process"); | ||
const exec = require("util").promisify(require("child_process").exec); | ||
const psTree = require("ps-tree"); | ||
|
||
// Check if a command is provided as an argument | ||
if (process.argv.length < 3) { | ||
console.log("Usage: node run-command.js <command>"); | ||
process.exit(1); | ||
} | ||
|
||
// Get the command from the command-line arguments | ||
const command = process.argv.slice(2).join(" "); | ||
|
||
// Run the command as a child process | ||
const childProcess = spawn(command, { | ||
shell: true, // Use the system shell to execute the command | ||
stdio: "inherit", //'inherit' // Use the same stdio as the parent process (console) | ||
}); | ||
|
||
console.log("the subprocess pid is " + childProcess.pid); | ||
console.log("the current process pid is " + process.pid); | ||
|
||
async function isPortOpen(childPid) { | ||
try { | ||
const { stdout } = await exec(`lsof | grep LISTEN | grep ${childPid}`); | ||
const includes = stdout.includes(`${childPid}`); | ||
|
||
if (includes) { | ||
const ports = Array.from(stdout.matchAll(/:(\d+)/g)).map((m) => +m[1]); | ||
console.log(ports); | ||
} | ||
|
||
return includes; | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
|
||
// Handle child process events | ||
childProcess.on("exit", (code) => { | ||
console.log(`Child process exited with code ${code}`); | ||
}); | ||
|
||
childProcess.on("error", (err) => { | ||
console.error("Child process error:", err); | ||
}); | ||
|
||
// Example usage: | ||
const targetPid = process.pid; // Get the target PID from the command line arguments | ||
|
||
const interval = setInterval(async () => { | ||
psTree(targetPid, async (err, children) => { | ||
if (err) { | ||
console.error("Error:", err); | ||
return; | ||
} | ||
|
||
const childrenWithPort = await Promise.all( | ||
children.map(async (child) => { | ||
return { | ||
isOpen: await isPortOpen(child.PID), | ||
pid: child.PID, | ||
}; | ||
}), | ||
); | ||
|
||
const openChildrenWithPort = childrenWithPort.filter( | ||
(child) => child.isOpen, | ||
); | ||
console.log(JSON.stringify(openChildrenWithPort)); | ||
}); | ||
}, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.