summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_controller.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-10-02Added routes array to the default configuration.Liam Crilly1-2/+3
The default configuration previously contained just a listeners and applications object. Since routes is now a principle configuration object, and a recommended way of configurating Unit, it is now included in the default configuration. This change benefits new users because it explicitly introduces the three principle configuration objects which leads more intuitively to the documentation. Experienced users may choose to ignore or delete routes. routes is defined as an array instead of an object because this change is designed to assist new users, where the simpler form of routes is easier to understand.
2023-05-08NJS: supported loadable modules.Zhidao HONG1-0/+353
2022-11-04Removed the unsafe nxt_memchr() wrapper for memchr(3).Alejandro Colomar1-1/+1
The casts are unnecessary, since memchr(3)'s argument is 'const void *'. It might have been necessary in the times of K&R, where 'void *' didn't exist. Nowadays, it's unnecessary, and _very_ unsafe, since casts can hide all classes of bugs by silencing most compiler warnings. The changes from nxt_memchr() to memchr(3) were scripted: $ find src/ -type f \ | grep '\.[ch]$' \ | xargs sed -i 's/nxt_memchr/memchr/' Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-04Removed the unsafe nxt_memcmp() wrapper for memcmp(3).Alejandro Colomar1-2/+2
The casts are unnecessary, since memcmp(3)'s arguments are 'void *'. It might have been necessary in the times of K&R, where 'void *' didn't exist. Nowadays, it's unnecessary, and _very_ unsafe, since casts can hide all classes of bugs by silencing most compiler warnings. The changes from nxt_memcmp() to memcmp(3) were scripted: $ find src/ -type f \ | grep '\.[ch]$' \ | xargs sed -i 's/nxt_memcmp/memcmp/' Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-10-03Socket: Created control socket & pid file directories.Andrew Clayton1-0/+8
@alejandro-colomar reported an issue on GitHub whereby Unit would fail to start due to not being able to create the control socket (a Unix Domain Socket) 2022/08/05 20:12:22 [alert] 21613#21613 bind(6, unix:/opt/local/unit/var/run/unit/control.unit.sock.tmp) failed (2: No such file or directory) This could happen if the control socket was set to a directory that doesn't exist. A common place to put the control socket would be under /run/unit, and while /run will exist, /run/unit may well not (/run is/should be cleared on each boot). The pid file would also generally go under /run/unit, though this is created after the control socket, however it could go someplace else so we should also ensure its directory exists. This commit will try to create the pid file and control sockets parent directory. In some cases the user will need to ensure that the rest of the path already exists. This adds a new nxt_fs_mkdir_parent() function that given a full path to a file (or directory), strips the last component off before passing the remaining directory path to nxt_fs_mkdir(). Cc: Konstantin Pavlov <thresh@nginx.com> Closes: <https://github.com/nginx/unit/issues/742> Reported-by: Alejandro Colomar <alx@nginx.com> Reviewed-by: Alejandro Colomar <alx@nginx.com> Tested-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2022-08-29Implemented basic statistics API.Valentin Bartenev1-4/+165
2022-07-02Increased readtimeout for configuration endpoint.Timo Stark1-1/+1
Closes: <https://github.com/nginx/unit/issues/676>
2021-10-09Configuration: automatic migration to the new "share" behavior.Zhidao HONG1-26/+81
2021-07-29Application restart introduced.Max Romanov1-0/+161
When processing a restart request, the router sends a QUIT message to all existing processes of the application. Then, a new shared application port is created to ensure that new requests won't be handled by the old processes of the application.
2021-02-03Using shared memory to pass configuration to main process.Max Romanov1-5/+32
This patch is required to remove fragmented messages functionality.
2020-08-11Style fixes for 2 file descriptors transfer over port.Max Romanov1-2/+2
Two consecutive fd and fd2 fields replaced with array.
2020-07-25Using plain shared memory for configuration pass.Max Romanov1-12/+38
There is no restrictions on configration size and using segmented shared memory only doubles memory usage because to parse configration on router side, it needs to be 'plain' e. g. located in single continous memory buffer.
2020-03-09Refactor of process management.Tiago Natel de Moura1-10/+132
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-12Waiting for router instead of reporting to user on config update.Max Romanov1-24/+25
2020-05-12Blocking config change when applying the initial router config.Max Romanov1-11/+32
2020-04-16Using malloc/free for the http fields hash.Max Romanov1-4/+1
This is required due to lack of a graceful shutdown: there is a small gap between the runtime's memory pool release and router process's exit. Thus, a worker thread may start processing a request between these two operations, which may result in an http fields hash access and subsequent crash. To simplify issue reproduction, it makes sense to add a 2 sec sleep before exit() in nxt_runtime_exit().
2020-04-08Controller: improved handling of unix domain control socket.Valentin Bartenev1-1/+1
One of the ways to detect Unit's startup and subsequent readiness to accept commands relies on waiting for the control socket file to be created. Earlier, it was unreliable due to a race condition between the client's connect() and the daemon's listen() calls after the socket's bind() call. Now, unix domain listening sockets are created with a nxt_listen_socket_create() call as follows: s = socket(); unlink("path/to/socket.tmp") bind(s, "path/to/socket.tmp"); listen(s); rename("path/to/socket.tmp", "path/to/socket"); This eliminates a time-lapse when the socket file is already created but nobody is listening on it yet, which therefore prevents the condition described above. Also, it allows reliably detecting whether the socket is being used or simply wasn't cleaned after the daemon stopped abruptly. A successful connection to the socket file means the daemon has been started; otherwise, the file can be overwritten.
2020-04-08Removed unused code related to testing of address binding.Valentin Bartenev1-1/+1
2020-04-08Controller: eliminated extra control socket's sockaddr copying.Valentin Bartenev1-11/+1
2020-02-20Configuration: removing UTF-8 BOM from the input JSON.Valentin Bartenev1-0/+7
Some editors can add it to JSON files.
2019-09-16Configuration: added ability to access object members with slashes.Valentin Bartenev1-0/+2
Now URI encoding can be used to escape "/" in the request path: GET /config/listeners/unix:%2Fpath%2Fto%2Fsocket/
2019-04-24Configuration: support for POST operations on arrays.Valentin Bartenev1-7/+27
It allows to add an array element without specifying the index.
2019-03-22Destroying pool in case of error.Max Romanov1-0/+1
This closes #233 issue on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
2018-09-20Preserving inherited engine memory pool in controller process.Max Romanov1-8/+0
The pool is inherited from master process since changeset 854a1a440616.
2018-09-20Controller: certificates storage interface.Valentin Bartenev1-18/+404
2018-07-02Controller: fixed handling of zero Content-Length.Valentin Bartenev1-1/+1
2018-06-25Introduced nxt_length() macro.Valentin Bartenev1-8/+8
2018-05-21Added SERVER_SOFTWARE request meta-variable.Valentin Bartenev1-2/+2
2018-04-26Controller waits READY message from router.Max Romanov1-14/+47
This required to avoid racing condition when controller receive router port before router receives controller port.
2018-04-17Added missing checks if nxt_port_rpc_register_handler() failed.Valentin Bartenev1-0/+4
This closes #97 issue on GitHub. Thanks to 洪志道 (Hong Zhi Dao).
2018-04-11Controller: added "/config" prefix for the configuration object.Valentin Bartenev1-0/+11
2018-04-08Controller: fixed a memory leak when PUT operation failed.Valentin Bartenev1-0/+2
Thanks to 洪志道 (Hong Zhi Dao).
2018-03-13Capitalization in the "Server" field.Valentin Bartenev1-2/+2
2018-03-05Reduced number of critical log levels.Valentin Bartenev1-6/+5
2017-12-25HTTP parser: reworked header fields handling.Valentin Bartenev1-24/+22
2017-11-27A number of engine connections is decreased on connection close.Igor Sysoev1-3/+1
2017-10-25Checking the result of shared memory buffer allocation.Max Romanov1-0/+3
This closes #57 issue on GitHub.
2017-10-18Router: fixed segfault after configuration change.Igor Sysoev1-1/+1
2017-10-10Basic validation errors.Valentin Bartenev1-18/+67
2017-10-04Using port 'post' facility to proxy remove pid message to workers.Max Romanov1-1/+1
Remove pid proxying to worker engines implementation was originally overcomplicated. Memory pool and 2 engine posts (there and back again) are optimized out and replaced with band new nxt_port_post() call.
2017-10-04Using engine memiory pool for port write allocations.Max Romanov1-1/+1
To allow use port from different threads, the first step is to avoid using port's memory pool for temporary allocations required to send data through the port. Including but not limited by: - buffers for data; - send message structures; - new mmap fd notifications; It is still safe to use port memory pool for incoming buffers allocations because recieve operation bound to single thread.
2017-09-27Event engine memory cache for nxt_sockaddr_t.Igor Sysoev1-0/+10
Introducing event engine memory cache and using the cache for nxt_sockaddr_t structures.
2017-09-15Introducing named port message handlers to avoid misprints.Max Romanov1-14/+9
2017-09-15Fixed port handlers arrays.Valentin Bartenev1-0/+1
2017-09-10Configuration persistence.Valentin Bartenev1-0/+87
Now configuration survives server reloads.
2017-09-14Fixed textual socket name lengths and Unix domain sockaddr length.Igor Sysoev1-3/+2
2017-08-31nginext has been renamed to unit.Igor Sysoev1-2/+2
2017-08-30Controller: resending configuration to router after its restart.Valentin Bartenev1-66/+116
Now router crash can be survived with less damage.
2017-08-30Controller: waiting for router before start to accept connections.Valentin Bartenev1-12/+48
Previously, reconfiguration might fail right after the daemon start if the router process wasn't ready yet.
2017-08-30Controller: correct handling of missing router port.Valentin Bartenev1-11/+41
There's no router port if the router process is just crashed or hasn't started yet.