summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_application.h (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-08-17Wasm: Add support for directory access.Andrew Clayton1-0/+2
Due to the sandboxed nature of WebAssembly, by default WASM modules don't have any access to the underlying filesystem. There is however a capabilities based mechanism[0] for allowing such access. This adds a config option to the 'wasm' application type; 'access.filesystem' which takes an array of directory paths that are then made available to the WASM module. This access works recursively, i.e everything under a specific path is allowed access to. Example config might look like "access" { "filesystem": [ "/tmp", "/var/tmp" ] } The actual mechanism used allows directories to be mapped differently in the guest. But at the moment we don't support that and just map say /tmp to /tmp. This can be revisited if it's something users clamour for. Network sockets are another resource that may be controlled in this manner, for example there is a wasi_config_preopen_socket() function, however this requires the runtime to open the network socket then effectively pass this through to the guest. This is something that can be revisited in the future if users desire it. [0]: <https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-capabilities.md> Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2023-08-16Wasm: Add core configuration data structure.Andrew Clayton1-0/+16
This is required to actually _build_ the Wasm language module. The nxt_wasm_app_conf_t structure consists of the modules name, e.g wasm, then the three required function handlers followed by the five optional function handlers. See the next commit for details of these function handlers. We also need to include the u.wasm union entry that provides access to the above structure. The bulk of the configuration infrastructure will be added in a subsequent commit. Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2023-08-10Wasm: Register a new WebAssembly language module type.Andrew Clayton1-0/+1
This is the first patch in adding WebAssembly language module support. This just adds a new NXT_APP_WASM type, required by subsequent commits. Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2023-04-11Add per-application logging.Andrew Clayton1-0/+4
Currently when running in the foreground, unit application processes will send stdout to the current TTY and stderr to the unit log file. That behaviour won't change. When running as a daemon, unit application processes will send stdout to /dev/null and stderr to the unit log file. This commit allows to alter the latter case of unit running as a daemon, by allowing applications to redirect stdout and/or stderr to specific log files. This is done via two new application options, 'stdout' & 'stderr', e.g "applications": { "myapp": { ... "stdout": "/path/to/log/unit/app/stdout.log", "stderr": "/path/to/log/unit/app/stderr.log" } } These log files are created by the application processes themselves and thus the log directories need to be writable by the user (and or group) of the application processes. E.g $ sudo mkdir -p /path/to/log/unit/app $ sudo chown APP_USER /path/to/log/unit/app These need to be setup before starting unit with the above config. Currently these log files do not participate in log-file rotation (SIGUSR1), that may change in a future commit. In the meantime these logs can be rotated using the traditional copy/truncate method. NOTE: You may or may not see stuff printed to stdout as stdout was traditionally used by CGI applications to communicate with the webserver. Closes: <https://github.com/nginx/unit/issues/197> Closes: <https://github.com/nginx/unit/issues/846> Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-12-14Removed dead code.OutOfFocus41-1/+0
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-17Removed dead code.OutOfFocus41-1/+0
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2021-11-24Sending shared port to application prototype.Max Romanov1-0/+3
Application process started with shared port (and queue) already configured. But still waits for PORT_ACK message from router to start request processing (so-called "ready state"). Waiting for router confirmation is necessary. Otherwise, the application may produce response and send it to router before the router have the information about the application process. This is a subject of further optimizations.
2021-10-28Moving request limit control to libunit.Max Romanov1-1/+2
Introducting application graceful stop. For now only used when application process reach request limit value. This closes #585 issue on GitHub.
2021-07-02Ruby: process and thread lifecycle hooks.Oisin Canty1-0/+1
This feature allows one to specify blocks of code that are called when certain lifecycle events occur. A user configures a "hooks" property on the app configuration that points to a script. This script will be evaluated on boot and should contain blocks of code that will be called on specific events. An example of configuration: { "type": "ruby", "processes": 2, "threads": 2, "user": "vagrant", "group": "vagrant", "script": "config.ru", "hooks": "hooks.rb", "working_directory": "/home/vagrant/unit/rbhooks", "environment": { "GEM_HOME": "/home/vagrant/.ruby" } } An example of a valid "hooks.rb" file follows: File.write("./hooks.#{Process.pid}", "hooks evaluated") on_worker_boot do File.write("./worker_boot.#{Process.pid}", "worker booted") end on_thread_boot do File.write("./thread_boot.#{Process.pid}.#{Thread.current.object_id}", "thread booted") end on_thread_shutdown do File.write("./thread_shutdown.#{Process.pid}.#{Thread.current.object_id}", "thread shutdown") end on_worker_shutdown do File.write("./worker_shutdown.#{Process.pid}", "worker shutdown") end This closes issue #535 on GitHub.
2021-05-20Python: support for multiple targets.Oisin Canty1-0/+1
2020-12-22Python: multiple values in the "path" option.Valentin Bartenev1-7/+7
2020-11-10Python: supporting ASGI legacy protocol.Max Romanov1-0/+1
Introducing manual protocol selection for 'universal' apps and frameworks.
2020-11-05Perl: request processing in multiple threads.Max Romanov1-0/+2
This closes #486 issue on GitHub.
2020-11-05Ruby: request processing in multiple threads.Max Romanov1-0/+1
This closes #482 issue on GitHub.
2020-11-05Java: request processing in multiple threads.Max Romanov1-0/+2
This closes #458 issue on GitHub.
2020-11-05Python: request processing in multiple threads.Max Romanov1-0/+2
This closes #459 issue on GitHub.
2020-09-18Python: app module callable name configuration.Max Romanov1-0/+1
Now it is possible to specify the name of the application callable using optional parameter 'callable'. Default value is 'application'. This closes #290 issue on GitHub.
2020-05-28Added "rootfs" feature.Tiago Natel de Moura1-0/+4
2020-03-09Refactor of process management.Tiago Natel de Moura1-7/+4
The process abstraction has changed to: setup(task, process) start(task, process_data) prefork(task, process, mp) The prefork() occurs in the main process right before fork. The file src/nxt_main_process.c is completely free of process specific logic. The creation of a process now supports a PROCESS_CREATED state. The The setup() function of each process can set its state to either created or ready. If created, a MSG_PROCESS_CREATED is sent to main process, where external setup can be done (required for rootfs under container). The core processes (discovery, controller and router) doesn't need external setup, then they all proceeds to their start() function straight away. In the case of applications, the load of the module happens at the process setup() time and The module's init() function has changed to be the start() of the process. The module API has changed to: setup(task, process, conf) start(task, data) As a direct benefit of the PROCESS_CREATED message, the clone(2) of processes using pid namespaces now doesn't need to create a pipe to make the child block until parent setup uid/gid mappings nor it needs to receive the child pid.
2020-05-14PHP: implemented "targets" option.Valentin Bartenev1-3/+3
This allows to specify multiple subsequent targets inside PHP applications. For example: { "listeners": { "*:80": { "pass": "routes" } }, "routes": [ { "match": { "uri": "/info" }, "action": { "pass": "applications/my_app/phpinfo" } }, { "match": { "uri": "/hello" }, "action": { "pass": "applications/my_app/hello" } }, { "action": { "pass": "applications/my_app/rest" } } ], "applications": { "my_app": { "type": "php", "targets": { "phpinfo": { "script": "phpinfo.php", "root": "/www/data/admin", }, "hello": { "script": "hello.php", "root": "/www/data/test", }, "rest": { "root": "/www/data/example.com", "index": "index.php" }, } } } }
2019-12-24Adding "limits/shm" configuration validation and parsing.Max Romanov1-0/+3
2019-09-19Initial applications isolation support using Linux namespaces.Tiago de Bem Natel de Moura1-0/+2
2019-03-06Removed unnecessary abstraction layer.Alexander Borisov1-56/+0
2019-02-28Introducing Java Servlet Container beta.Max Romanov1-0/+12
2019-02-27Fixed processing of SERVER_NAME after 77aad2c142a0.Valentin Bartenev1-1/+1
Previously, the nxt_router_prepare_msg() function expected server host among other headers unmodified. It's not true anymore since normalization of the Host header has been introduced in 77aad2c142a0. The nxt_unit_split_host() function was removed. It didn't work correctly with IPv6 literals. Anyway, after 77aad2c142a0 the port splitting is done in router while Host header processing.
2018-10-09Renamed "go" application type to "external".Valentin Bartenev1-13/+13
There's nothing specific to Go language. This type of application object can be used to run any external application that utilizes libunit API.
2018-08-06Unit application library.Max Romanov1-153/+9
Library now used in all language modules. Old 'nxt_app_*' code removed. See src/test/nxt_unit_app_test.c for usage sample.
2018-07-11Removed unused "nxt_app_header_field_t" structure.Valentin Bartenev1-6/+0
It's not used since 3b77edf46701.
2018-06-25Introduced nxt_length() macro.Valentin Bartenev1-2/+2
2018-06-07PHP: added setting of php.ini configuration file path.Valentin Bartenev1-3/+4
2018-06-06Go: specifying command line arguments to the executable.Valentin Bartenev1-1/+2
This closes #110 issue on GitHub.
2018-05-28Configuration of environment variables for application processes.Valentin Bartenev1-5/+9
2018-05-21Added SERVER_SOFTWARE request meta-variable.Valentin Bartenev1-0/+1
2018-04-05Stopping timed out application process.Max Romanov1-0/+1
2018-04-05Style.Valentin Bartenev1-4/+4
2018-04-04Changed version processing for modules.Alexander Borisov1-1/+1
2018-04-04Style: capitalized letters in hexadecimal literals.Valentin Bartenev1-1/+1
2018-03-21Added Ruby support.Alexander Borisov1-1/+9
2018-01-31Added Perl support.Alexander Borisov1-1/+8
2018-01-29Introducing extended app process management.Max Romanov1-2/+0
- Pre-fork 'processes.spare' application processes; - fork more processes to keep 'processes.spare' idle processes; - fork on-demand up to 'processes.max' count; - scale down idle application processes above 'processes.spare' after 'processes.idle_timeout'; - number of concurrently started application processes also limited by 'processes.spare' (or 1, if spare is 0).
2018-01-11Changing relative php scripts paths to real ones.Max Romanov1-1/+1
This is required to run phpMyAdmin.
2017-12-28Removed duplicate declaration.Igor Sysoev1-2/+0
2017-12-28HTTP keep-alive connections support.Igor Sysoev1-12/+6
2017-12-27Introducing application 'atexit' hook.Max Romanov1-0/+1
Finalizing Python interpreter. This closes #65 issue on GitHub.
2017-12-25HTTP parser: reworked header fields handling.Valentin Bartenev1-1/+1
2017-11-29Introducing python virtualenv configuration.Max Romanov1-0/+1
New parameter 'home' for python application allows to configure application-specific virtualenv path. This closes #15 issue on GitHub.
2017-10-10Optimized application type handling.Valentin Bartenev1-2/+1
2017-10-05Improved applications versions handling.Valentin Bartenev1-1/+1
2017-09-15Fixing memory leak of request parse context.Max Romanov1-1/+1
2017-09-06Style fixes.Igor Sysoev1-0/+2