view xml/en/docs/njs/cli.xml @ 2846:fdf1464e1977

Moved banner to the external file to make partial rollout possible. An idea is to have several banners and show them with different probability specified by split directive in the nginx.conf
author Sergey Budnevitch <sb@waeme.net>
date Tue, 10 May 2022 18:07:27 +0400
parents bb0a2fbdc886
children
line wrap: on
line source

<?xml version="1.0"?>

<!--
  Copyright (C) Nginx, Inc.
  -->

<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">

<article name="Command-line interface"
        link="/en/docs/njs/cli.html"
        lang="en"
        rev="4">

<section>
<para>
njs scripts development and debugging can be performed
from the command-line.
The command-line utility is available after the installation of
the Linux <link doc="install.xml" id="install_package">package</link>
or after building from the
<link doc="install.xml" id="install_sources">sources</link>.
Compared to njs running inside nginx,
nginx objects
(<link doc="reference.xml" id="http">HTTP</link> and
<link doc="reference.xml" id="stream">Stream</link>)
are not available in the utility.
<example>
$ echo "2**3" | njs -q
8

$ 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]
}
>>
</example>
</para>

</section>

</article>