NETSCRIPT: Greatly speed up script launching, and remove the limitation unique args per script (#440)

* Remove the limitation unique args per script
* Internal changes to how runningScripts are stored on the server, to make common usage faster.
This commit is contained in:
David Walker
2023-04-27 15:21:06 -07:00
committed by GitHub
parent f81297dcd6
commit aa7facd4ba
44 changed files with 573 additions and 493 deletions

View File

@@ -31,8 +31,16 @@ Many commands and functions act on an executing script
be a way to specify which script you want those commands & functions
to act on.
**A script that is being executed is uniquely identified by both its
name and the arguments that it was run with.**
The best way to identify a script is by its PID (Process IDentifier). This
unique number is returned from :js:func:`run`, :js:func:`exec`, etc., and also
shows in the output of "ps".
A secondary way to identify scripts is by name **and** arguments. However (by
default) you can run a multiple copies of a script with the same arguments, so
this does not necessarily **uniquely** identify a script. In case of multiple
matches, most functions will return an arbitrary one (typically the first one
to be started). An exception is :js:func:`kill`, which will kill all the
matching scripts.
The arguments must be an **exact** match. This means that both
the order and type of the arguments matter.
@@ -88,12 +96,12 @@ to the check command::
Shows the current server's RAM usage and availability
**kill [script] [args...]**
**kill [pid]** or **kill [script] [args...]**
Stops a script that is running with the specified script name and
Stops a script that is running with the specified PID, or script name and
arguments. Arguments should be separated by a space. Remember that
scripts are uniquely identified by their arguments as well as
their name. For example, if you ran a script `foo.js` with
scripts are identified by their arguments as well as their name.
For example, if you ran a script `foo.js` with
the argument 1 and 2, then just typing "`kill foo.js`" will
not work. You have to use::
@@ -142,13 +150,13 @@ Run 'foo.js' with 50 threads and a single argument: [foodnstuff]::
$ run foo.js -t 50 foodnstuff
**tail [script] [args...]**
**tail [pid]** or **tail [script] [args...]**
Displays the logs of the script specified by the name and arguments. Note that scripts
are uniquely identified by their arguments as well as their name. For example, if you
ran a script 'foo.js' with the argument 'foodnstuff' then in order to 'tail' it you
must also add the 'foodnstuff' argument to the tail command as so: tail foo.js
foodnstuff
Displays the logs of the script specified by the PID or name and arguments. Note that
scripts are identified by their arguments as well as their name. For example,
if you ran a script 'foo.js' with the argument 'foodnstuff' then in order to
'tail' it you must also add the 'foodnstuff' argument to the tail command as
so: tail foo.js foodnstuff
**top**

View File

@@ -318,7 +318,7 @@ to home and want to kill a script running on n00dles, you have to either use it'
or :code:`connect` to n00dles first and then use the the kill command.
If you are killing the script using its filename and arguments, then each argument
must be separated by a space. Remember that a running script is uniquely identified
must be separated by a space. Remember that a running script is identified
by both its name and the arguments that are used to start it. So, if a script
was ran with the following arguments::
@@ -328,6 +328,9 @@ Then to kill this script the same arguments would have to be used::
$ kill foo.js 50e3 sigma-cosmetics
If there are multiple copies of a script running with the same arguments, all
of them will be killed.
If you are killing the script using its PID, then the PID argument must be numeric.
killall
@@ -543,11 +546,13 @@ Prints whether or not you have root access to the current server.
tail
^^^^
$ tail [pid]
or
$ tail [script name] [args...]
Displays dynamic logs for the script specified by the script name and arguments.
Displays dynamic logs for the script specified by PID or the script name and arguments.
Each argument must be separated by a space. Remember that a running script is
uniquely identified by both its name and the arguments that were used to run
identified by both its name and the arguments that were used to run
it. So, if a script was ran with the following arguments::
$ run foo.js 10 50000
@@ -642,3 +647,6 @@ with a semicolon (;).
Example::
$ run foo.js; tail foo.js
This does *not* wait for commands with a delay to finish executing, so it
generally doesn't work with things like :code:`hack`, :code:`wget`, etc.