- Source:
System and process utilities
Members
(static) sleep
- Source:
Sleep for a specified time (in milliseconds)
Example: await System.sleep(2000);
(static) tick
- Source:
wait till the next event loop cycle
this function is useful if we are running a long blocking task
and need to make sure that other callbacks can complete.
Methods
(async, static) exec(command, options) → {Promise.<processObject>}
- Source:
Execute the given command in a shell.
Parameters:
Name | Type | Description |
---|---|---|
command |
string | |
options |
object | options object |
Returns:
- Type
- Promise.<processObject>
(async, static) execFile(…args) → {Promise.<processObject>}
- Source:
Similar to exec but instead executes a given file
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
Array.<any> |
<repeatable> |
Returns:
- Type
- Promise.<processObject>
(async, static) execFileOut(…args) → {string}
- Source:
execute a file and return its output
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
Array.<any> |
<repeatable> |
Returns:
output of the file's execution
- Type
- string
(async, static) execOut(…args) → {string}
- Source:
execute a command and return its output
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
Array.<any> |
<repeatable> |
Returns:
output of the command's execution
- Type
- string
(static) exit(code) → {void}
- Source:
exit and kill the process gracefully (after completing all onExit handlers)
code can be an exit code or a message (string)
if a message is given then it will be logged to console before exiting
Parameters:
Name | Type | Description |
---|---|---|
code |
number | string | exit code or the message to be logged |
Returns:
- Type
- void
(static) forceExit(code) → {void}
- Source:
force exit the process
no onExit handler will run when force exiting a process
same as original process.exit (which we override)
Parameters:
Name | Type | Description |
---|---|---|
code |
number | string | exit code or the message to be logged |
Returns:
- Type
- void
(async, static) getAllUsers() → {object}
- Source:
get all users in the system
currently gets user info from /etc/passwd
Returns:
object containing info for all users, as username:info pairs
- Type
- object
(async, static) getGitBranch() → {string}
- Source:
get the current git branch name (in cwd)
Returns:
the current branch name, empty string if not found
- Type
- string
(static) getuid() → {number}
- Source:
get the uid of the user running current process
Returns:
uid
- Type
- number
(async, static) getUserInfo(user) → {object}
- Source:
get user info from username or uid
currently gets user info from /etc/passwd
Parameters:
Name | Type | Description |
---|---|---|
user |
string | number | username or uid |
Returns:
the user's information
- Type
- object
(static) gracefulServerExit(server, optionsopt)
- Source:
install graceful server exit handler on a tcp server
this will make sure that the process exits only
after all the current requests are served
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
server |
* | |||
options |
number | timeoutOpts |
<optional> |
{}
|
(static) microtime() → {number}
- Source:
get current time in microseconds (as double)
Returns:
current time in microseconds
- Type
- number
(static) millitime() → {number}
- Source:
get current time in milliseconds (as double)
Returns:
current time in milliseconds
- Type
- number
(static) nanotime() → {number}
- Source:
get current time in nanoseconds (as double)
Returns:
current time in nanoseconds
- Type
- number
(static) noUmask() → {number}
- Source:
turn off umask for the current process
Returns:
the old umask
- Type
- number
(static) onExit(callback, optionsopt) → {Promise.<void>}
- Source:
Add an exit handler that runs when process receives an exit signal
callback can be an async function, process will exit when all handlers have completed
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function | function to call on exit |
||
options |
number | timeoutOpts |
<optional> |
{}
|
can be {timeout} or a number |
Returns:
- Type
- Promise.<void>
(static) setMaxMemory(memory)
- Source:
set the max memory that the current node process can use
Parameters:
Name | Type | Description |
---|---|---|
memory |
number | max memory in megabytes |
(static) time() → {number}
- Source:
get current time in seconds
Returns:
current time in seconds
- Type
- number
(static) yesUmask() → {number}
- Source:
restores (turns on) the previous umask
Returns:
new umask
- Type
- number