mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 12:27:07 +02:00
MISC: Improve several things relating to PID lookups (#1594)
findRunningScriptByPid needlessly took a "server" argument. This caused there to be a "getRunningScriptByPid" version that did *not*, and it was looping through all servers in order to function, which is needlessly inefficient. By removing the parameter and the needless inefficient helper method, the following changes: - Many Netscript functions such as isRunning() and getScript() become faster. - The terminal "tail" command now works by pid regardless of the current server. Note that "kill" already worked this way. I also improved the docs around "tail", since the pid argument wasn't in the help.
This commit is contained in:
@@ -32,14 +32,14 @@ export const TerminalHelpText: string[] = [
|
||||
" mv [src] [dest] Move/rename a text or script file",
|
||||
" nano [files...] Text editor - Open up and edit one or more scripts or text files",
|
||||
" ps Display all scripts that are currently running",
|
||||
" rm [OPTIONS]... [FILE]... Delete a file from the server",
|
||||
" rm [OPTIONS]... [FILE]... Delete a file from the server",
|
||||
" run [script] [-t n] [--tail] Execute a program or script",
|
||||
" [--ram-override n] [args...]",
|
||||
" scan Prints all immediately-available network connections",
|
||||
" scan-analyze [d] [-a] Prints info for all servers up to d nodes away",
|
||||
" scp [files...] [server] Copies a file to a destination server",
|
||||
" sudov Shows whether you have root access on this computer",
|
||||
" tail [script] [args...] Displays dynamic logs for the specified script",
|
||||
" tail [script/pid] [args...] Displays dynamic logs for the specified script",
|
||||
" top Displays all running scripts and their RAM usage",
|
||||
" unalias [alias name] Deletes the specified alias",
|
||||
" vim [files...] Text editor - Open up and edit one or more scripts or text files in vim mode",
|
||||
|
||||
@@ -7,7 +7,7 @@ import { hasScriptExtension } from "../../Paths/ScriptFilePath";
|
||||
export function tail(commandArray: (string | number | boolean)[], server: BaseServer): void {
|
||||
try {
|
||||
if (commandArray.length < 1) {
|
||||
Terminal.error("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]...");
|
||||
Terminal.error("Incorrect number of arguments. Usage: tail [pid] or tail [scriptname] [arg1] [arg2]...");
|
||||
} else if (typeof commandArray[0] === "string") {
|
||||
const [rawName, ...args] = commandArray;
|
||||
const path = Terminal.getFilepath(rawName);
|
||||
@@ -25,9 +25,9 @@ export function tail(commandArray: (string | number | boolean)[], server: BaseSe
|
||||
// arguments, they can't be distinguished except by pid).
|
||||
LogBoxEvents.emit(candidates.values().next().value);
|
||||
} else if (typeof commandArray[0] === "number") {
|
||||
const runningScript = findRunningScriptByPid(commandArray[0], server);
|
||||
const runningScript = findRunningScriptByPid(commandArray[0]);
|
||||
if (runningScript == null) {
|
||||
Terminal.error(`No script with PID ${commandArray[0]} is running on the server`);
|
||||
Terminal.error(`No script with PID ${commandArray[0]} is running`);
|
||||
return;
|
||||
}
|
||||
LogBoxEvents.emit(runningScript);
|
||||
|
||||
Reference in New Issue
Block a user