Appearance
命令行接口
提示
来自deepseek解释
原文链接:https://nginx.org/en/docs/njs/cli.html
njs 脚本的开发和调试可以在命令行中进行。命令行工具在安装 Linux 软件包 或从源码构建后即可使用。
与在 nginx 内部运行 njs 相比,该工具中不提供 nginx 对象(HTTP 和 Stream)。
bash
$ echo "2**3" | njs -q
8bash
$ njs
>> globalThis
global {
njs: njs { version: '0.3.9' },
global: [Circular],
process: process {
argv: [ '/usr/bin/njs' ],
env: {
PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
HOSTNAME: 'f777c149d4f8',
TERM: 'xterm',
NGINX_VERSION: '1.17.9',
NJS_VERSION: '0.3.9',
PKG_RELEASE: '1~buster',
HOME: '/root'
}
},
console: {
log: [Function: native],
dump: [Function: native],
time: [Function: native],
timeEnd: [Function: native]
},
print: [Function: native]
}
>>