Opened 16 months ago

Last modified 7 months ago

#2465 new enhancement

Execute system commands with njs (JavaScript)

Reported by: anthumchris@… Owned by:
Priority: major Milestone:
Component: other Version: 1.23.x
Keywords: njs Cc:
uname -a: Darwin localhost 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64 x86_64
nginx -V: nginx version: nginx/1.23.3
built by clang 14.0.0 (clang-1400.0.29.202)
built with OpenSSL 3.0.8 7 Feb 2023
TLS SNI support enabled
configure arguments: --add-module=../nginx-njs/nginx --add-dynamic-module=../nginx-njs/nginx --with-openssl=../openssl-3.0.8 --with-compat --with-http_ssl_module --with-http_v2_module --with-threads --without-http_ssi_module --without-mail_imap_module --without-mail_pop3_module --without-mail_smtp_module --without-stream_access_module --without-stream_geo_module --without-stream_limit_conn_module --without-stream_map_module --without-stream_return_module --without-stream_set_module --without-stream_split_clients_module --without-stream_upstream_hash_module --without-stream_upstream_least_conn_module --without-stream_upstream_random_module --without-stream_upstream_zone_module


Executing system commands in njs scripts could be very useful. Immediate use cases are:

  1. Executing a media codec command to return the byte position within a media file at a specific time (milliseconds).
  2. Executing an image resizing command to create smaller images (thumbnails) when original, full-size images are uploaded.

Additionally, providing input/output to system commands would provide us with a simple API to extend functionality beyond what njs natively provides.

Currently, Lua module lua-resty-shell provides a feature to execute commands. It would be great to have this in njs too.

Change History (0)

Note: See TracTickets for help on using tickets.