Handling change file message in libunit.
This is required for proper log file rotation action.
This commit is contained in:
@@ -767,6 +767,16 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id,
|
||||
case _NXT_PORT_MSG_CHANGE_FILE:
|
||||
nxt_unit_debug(ctx, "#%"PRIu32": change_file: fd %d",
|
||||
port_msg->stream, recv_msg.fd);
|
||||
|
||||
if (dup2(recv_msg.fd, lib->log_fd) == -1) {
|
||||
nxt_unit_alert(ctx, "#%"PRIu32": dup2(%d, %d) failed: %s (%d)",
|
||||
port_msg->stream, recv_msg.fd, lib->log_fd,
|
||||
strerror(errno), errno);
|
||||
|
||||
goto fail;
|
||||
}
|
||||
|
||||
rc = NXT_UNIT_OK;
|
||||
break;
|
||||
|
||||
case _NXT_PORT_MSG_MMAP:
|
||||
|
||||
@@ -2,7 +2,7 @@ def application(environ, start_response):
|
||||
content_length = int(environ.get('CONTENT_LENGTH', 0))
|
||||
body = bytes(environ['wsgi.input'].read(content_length))
|
||||
|
||||
environ['wsgi.errors'].write(body)
|
||||
environ['wsgi.errors'].write(body.decode())
|
||||
environ['wsgi.errors'].flush()
|
||||
|
||||
start_response('200', [('Content-Length', '0')])
|
||||
|
||||
@@ -51,7 +51,6 @@ class TestUSR1(TestApplicationPython):
|
||||
self.search_in_log(r'/usr1', log_new), 'rename new 2'
|
||||
)
|
||||
|
||||
@unittest.skip('not yet')
|
||||
def test_usr1_unit_log(self):
|
||||
self.load('log_body')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user