进程处理模块,用以管理当前进程的资源
引用方法:
var process = require('process');
| Type | Method and Description |
|---|---|
| readonly Array | public static readonly Array argvargvargv返回当前进程的命令行参数 |
| readonly Array | public static readonly Array execArgvexecArgvexecArgv返回当前进程的特殊命令行参数,这些参数被 fibjs 用于设置运行环境 |
| readonly String | public static readonly String versionversionversion返回fibjs版本字符串 |
| readonly String | public static readonly String execPathexecPathexecPath查询当前运行执行文件完整路径 |
| readonly Object | public static readonly Object envenvenv查询当前进程的环境变量 |
| readonly String | public static readonly String archarcharch查询当前 cpu 环境,可能的结果为 ‘amd64’, ‘arm’, ‘arm64’, ‘ia32’ |
| readonly String | public static readonly String platformplatformplatform查询当前平台名称,可能的结果为 ‘darwin’, ‘freebsd’, ‘linux’, 或 ‘win32’ |
| Type | Method and Description |
|---|---|
| Integer | umask(Integer mask)改变当前的 umask,Windows 不支持此方法 |
| Integer | umask(String mask)改变当前的 umask,Windows 不支持此方法 |
| Integer | umask()返回当前的 umask,Windows 不支持此方法 |
| void | exit(Integer code)退出当前进程,并返回结果 |
| String | cwd()返回操作系统当前工作路径 |
| void | chdir(String directory)修改操作系统当前工作路径 |
| Number | uptime()查询运行环境运行时间,以秒为单位 |
| Object | memoryUsage()查询当前进程内存使用报告 |
| void | nextTick(Function func,...)启动一个纤程 |
| SubProcess | open(String command,Array args,Object opts)运行指定的命令行,接管进程输入输出流,并返回进程对象 |
| SubProcess | open(String command,Object opts)运行指定的命令行,接管进程输入输出流,并返回进程对象 |
| SubProcess | start(String command,Array args,Object opts)运行指定的命令行,并返回进程对象 |
| SubProcess | start(String command,Object opts)运行指定的命令行,并返回进程对象 |
| Integer | run(String command,Array args,Object opts)运行指定的命令行,并返回进程的结束代码 |
| Integer | run(String command,Object opts)运行指定的命令行,并返回进程的结束代码 |
public static readonly Array argvargvargv返回当前进程的命令行参数
public static readonly Array execArgvexecArgvexecArgv返回当前进程的特殊命令行参数,这些参数被 fibjs 用于设置运行环境
public static readonly String versionversionversion返回fibjs版本字符串
public static readonly String execPathexecPathexecPath查询当前运行执行文件完整路径
public static readonly Object envenvenv查询当前进程的环境变量
public static readonly String archarcharch查询当前 cpu 环境,可能的结果为 ‘amd64’, ‘arm’, ‘arm64’, ‘ia32’
public static readonly String platformplatformplatform查询当前平台名称,可能的结果为 ‘darwin’, ‘freebsd’, ‘linux’, 或 ‘win32’
umask(Integer mask)改变当前的 umask,Windows 不支持此方法
mask 指定新的掩码返回之前的 mask
umask(String mask)改变当前的 umask,Windows 不支持此方法
mask 指定新的掩码, 字符串类型八进制(e.g: “0664”)返回之前的 mask
umask()返回当前的 umask,Windows 不支持此方法
返回当前的 mask 值
exit(Integer code)退出当前进程,并返回结果
code 返回进程结果cwd()返回操作系统当前工作路径
返回当前系统路径
chdir(String directory)修改操作系统当前工作路径
directory 指定设定的新路径uptime()查询运行环境运行时间,以秒为单位
返回表示时间的数值
memoryUsage()查询当前进程内存使用报告
返回包含内存报告
内存报告生成类似以下结果:
{
"rss": 8622080,
"heapTotal": 4083456,
"heapUsed": 1621800
}
其中:
rss 返回进程当前占用物理内存大小
heapTotal 返回 v8 引擎堆内存大小
heapUsed 返回 v8 引擎正在使用堆内存大小
nextTick(Function func,...)启动一个纤程
func 制定纤程执行的函数
... 可变参数序列,此序列会在纤程内传递给函数
open(String command,Array args,Object opts)运行指定的命令行,接管进程输入输出流,并返回进程对象
command 指定运行的命令行
args 指定运行的参数列表
opts 指定运行的选项,支持的选项如下:
{
"timeout": 100, // 单位为 ms
"envs": [] // 进程环境变量
}
返回包含运行结果的进程对象
open(String command,Object opts)运行指定的命令行,接管进程输入输出流,并返回进程对象
command 指定运行的命令行
opts 指定运行的选项,支持的选项如下:
{
"timeout": 100, // 单位为 ms
"envs": [] // 进程环境变量
}
返回包含运行结果的进程对象
start(String command,Array args,Object opts)运行指定的命令行,并返回进程对象
command 指定运行的命令行
args 指定运行的参数列表
opts 指定运行的选项,支持的选项如下:
{
"timeout": 100, // 单位为 ms
"envs": [] // 进程环境变量
}
返回包含运行结果的进程对象
start(String command,Object opts)运行指定的命令行,并返回进程对象
command 指定运行的命令行
opts 指定运行的选项,支持的选项如下:
{
"timeout": 100, // 单位为 ms
"envs": [] // 进程环境变量
}
返回包含运行结果的进程对象
run(String command,Array args,Object opts)运行指定的命令行,并返回进程的结束代码
command 指定运行的命令行
args 指定运行的参数列表
opts 指定运行的选项,支持的选项如下:
{
"timeout": 100, // 单位为 ms
"envs": [] // 进程环境变量
}
返回命令的运行结果
run(String command,Object opts)运行指定的命令行,并返回进程的结束代码
command 指定运行的命令行
opts 指定运行的选项,支持的选项如下:
{
"timeout": 100, // 单位为 ms
"envs": [] // 进程环境变量
}
返回命令的运行结果