<feed xmlns='http://www.w3.org/2005/Atom'>
<title>unit.git/src, branch applog</title>
<subtitle>Universal Web Application Server</subtitle>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/'/>
<entry>
<title>Handle log-rotation for the per-application logs.</title>
<updated>2023-04-06T18:42:22+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-30T05:06:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=d478eb5eeb53a64b39ff44173fa4b4fd6e224158'/>
<id>d478eb5eeb53a64b39ff44173fa4b4fd6e224158</id>
<content type='text'>
This commit makes the per-applications logs (if set) partake in logfile
rotation. This occurs when the master unit process receives a SIGUSR1.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit makes the per-applications logs (if set) partake in logfile
rotation. This occurs when the master unit process receives a SIGUSR1.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add per-application logging.</title>
<updated>2023-04-06T18:42:22+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-30T04:53:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=dc0a2a721abe133974fa3c5a1afdc4345df640a3'/>
<id>dc0a2a721abe133974fa3c5a1afdc4345df640a3</id>
<content type='text'>
This adds main part of per-application logging.

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' &amp;
'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.

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: &lt;https://github.com/nginx/unit/issues/197&gt;
Closes: &lt;https://github.com/nginx/unit/issues/846&gt;
Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds main part of per-application logging.

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' &amp;
'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.

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: &lt;https://github.com/nginx/unit/issues/197&gt;
Closes: &lt;https://github.com/nginx/unit/issues/846&gt;
Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add nxt_file_stdout().</title>
<updated>2023-04-06T18:42:16+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-30T04:44:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=5fbc363fc2d2c7463072235d35a7a83b5bdab6c0'/>
<id>5fbc363fc2d2c7463072235d35a7a83b5bdab6c0</id>
<content type='text'>
This is analogous to the nxt_file_stderr() function and will be used in
a subsequent commit.

This function redirects stdout to a given file descriptor.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is analogous to the nxt_file_stderr() function and will be used in
a subsequent commit.

This function redirects stdout to a given file descriptor.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove a useless assignment in nxt_mem_zone_alloc_pages().</title>
<updated>2023-04-03T13:53:04+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-15T03:48:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=485205712433611ee9939a869b4f734f824a177a'/>
<id>485205712433611ee9939a869b4f734f824a177a</id>
<content type='text'>
This was reported by the 'Clang Static Analyzer' as a 'dead nested
assignment'.

We assign prev_size then check if it's != 0 and if true we then set
prev_pages to page_size right shifted by two at the same time setting
prev_size to be right shifted by two (&gt;&gt;=), however page_size is never
used again so no need to set it here.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This was reported by the 'Clang Static Analyzer' as a 'dead nested
assignment'.

We assign prev_size then check if it's != 0 and if true we then set
prev_pages to page_size right shifted by two at the same time setting
prev_size to be right shifted by two (&gt;&gt;=), however page_size is never
used again so no need to set it here.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Prevent a possible NULL de-reference in nxt_job_create().</title>
<updated>2023-04-03T13:53:04+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-14T17:31:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=8a9e078e5427e2b72e178740f25cbcebb780b225'/>
<id>8a9e078e5427e2b72e178740f25cbcebb780b225</id>
<content type='text'>
We allocate 'job' we then have a check if it's not NULL and do stuff
with it, but then we accessed it outside this check.

Simply return if job is NULL.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We allocate 'job' we then have a check if it's not NULL and do stuff
with it, but then we accessed it outside this check.

Simply return if job is NULL.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove a useless assignment in nxt_fs_mkdir_all().</title>
<updated>2023-04-03T13:53:04+00:00</updated>
<author>
<name>Andrew Clayton</name>
<email>a.clayton@nginx.com</email>
</author>
<published>2023-03-14T17:21:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=22993fe41a65b7fc4215f2378e1251c790db0ecc'/>
<id>22993fe41a65b7fc4215f2378e1251c790db0ecc</id>
<content type='text'>
This was reported by the 'Clang Static Analyzer' as a 'dead nested
assignment'.

We set end outside the loop but the first time we use it is to assign it
in the loop (not used anywhere else).

Further cleanup could be to reduce the scope of end by moving its
declaration inside the loop.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This was reported by the 'Clang Static Analyzer' as a 'dead nested
assignment'.

We set end outside the loop but the first time we use it is to assign it
in the loop (not used anywhere else).

Further cleanup could be to reduce the scope of end by moving its
declaration inside the loop.

Reviewed-by: Alejandro Colomar &lt;alx@nginx.com&gt;
Signed-off-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Auto: mirroring installation structure in build tree.</title>
<updated>2023-03-28T22:41:08+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx@nginx.com</email>
</author>
<published>2023-03-22T15:55:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=6e16d7ac5bb86140a55ea30a35c69ee0df3eff8d'/>
<id>6e16d7ac5bb86140a55ea30a35c69ee0df3eff8d</id>
<content type='text'>
This makes the build tree more organized, which is good for adding new
stuff.  Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.

Previously, the build tree was quite flat, and looked like this (after
`./configure &amp;&amp; make`):

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── echo
    ├── libnxt.a
    ├── nxt_auto_config.h
    ├── nxt_version.h
    ├── unitd
    └── unitd.8

    1 directory, 9 files

And after this patch, it looks like this:

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── bin
    │   └── echo
    ├── include
    │   ├── nxt_auto_config.h
    │   └── nxt_version.h
    ├── lib
    │   ├── libnxt.a
    │   └── unit
    │       └── modules
    ├── sbin
    │   └── unitd
    ├── share
    │   └── man
    │       └── man8
    │           └── unitd.8
    └── var
        ├── lib
        │   └── unit
        ├── log
        │   └── unit
        └── run
            └── unit

    17 directories, 9 files

It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames.").  Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`).  Now, since it expects files in a very specific
location, that has been broken.  By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:

    $ ./configure --prefix=./build
    $ make
    $ ./build/sbin/unitd

Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly &lt;liam@nginx.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Cc: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This makes the build tree more organized, which is good for adding new
stuff.  Now, it's useful for example for adding manual pages in man3/,
but it may be useful in the future for example for extending the build
system to run linters (e.g., clang-tidy(1), Clang analyzer, ...) on the
C source code.

Previously, the build tree was quite flat, and looked like this (after
`./configure &amp;&amp; make`):

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── echo
    ├── libnxt.a
    ├── nxt_auto_config.h
    ├── nxt_version.h
    ├── unitd
    └── unitd.8

    1 directory, 9 files

And after this patch, it looks like this:

    $ tree -I src build
    build
    ├── Makefile
    ├── autoconf.data
    ├── autoconf.err
    ├── bin
    │   └── echo
    ├── include
    │   ├── nxt_auto_config.h
    │   └── nxt_version.h
    ├── lib
    │   ├── libnxt.a
    │   └── unit
    │       └── modules
    ├── sbin
    │   └── unitd
    ├── share
    │   └── man
    │       └── man8
    │           └── unitd.8
    └── var
        ├── lib
        │   └── unit
        ├── log
        │   └── unit
        └── run
            └── unit

    17 directories, 9 files

It also solves one issue introduced in
5a37171f733f ("Added default values for pathnames.").  Before that
commit, it was possible to run unitd from the build system
(`./build/unitd`).  Now, since it expects files in a very specific
location, that has been broken.  By having a directory structure that
mirrors the installation, it's possible to trick it to believe it's
installed, and run it from there:

    $ ./configure --prefix=./build
    $ make
    $ ./build/sbin/unitd

Fixes: 5a37171f733f ("Added default values for pathnames.")
Reported-by: Liam Crilly &lt;liam@nginx.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Cc: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Renamed --libstatedir to --statedir.</title>
<updated>2023-03-28T22:40:40+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx@nginx.com</email>
</author>
<published>2023-03-27T11:43:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=5ba79b9b524ef746bc3269520c3f6b893f39275c'/>
<id>5ba79b9b524ef746bc3269520c3f6b893f39275c</id>
<content type='text'>
In BSD systems, it's usually &lt;/var/db&gt; or some other dir under &lt;/var&gt;
that is not &lt;/var/lib&gt;, so $statedir is a more generic name.  See
hier(7).

Reported-by: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Reported-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In BSD systems, it's usually &lt;/var/db&gt; or some other dir under &lt;/var&gt;
that is not &lt;/var/lib&gt;, so $statedir is a more generic name.  See
hier(7).

Reported-by: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Reported-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Reviewed-by: Konstantin Pavlov &lt;thresh@nginx.com&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Liam Crilly &lt;liam@nginx.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>HTTP: added route logging.</title>
<updated>2023-03-21T12:02:38+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx@nginx.com</email>
</author>
<published>2023-01-26T14:07:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=0ebce31c9287cb97b626d61b62e83681b2864fe8'/>
<id>0ebce31c9287cb97b626d61b62e83681b2864fe8</id>
<content type='text'>
-  Configuration: added "/config/settings/http/log_route".

   Type: bool
   Default: false

   This adds configurability to the error log.  It allows enabling and
   disabling logs related to how the router performs selection of the
   routes.

-  HTTP: logging request line.

   Log level: [notice]

   The request line is essential to understand which logs correspond to
   which request when reading the logs.

-  HTTP: logging route that's been discarded.

   Log level: [info]

-  HTTP: logging route whose action is selected.

   Log level: [notice]

-  HTTP: logging when "fallback" action is taken.

   Log level: [notice]

Closes: &lt;https://github.com/nginx/unit/issues/758&gt;
Link: &lt;https://github.com/nginx/unit/pull/824&gt;
Link: &lt;https://github.com/nginx/unit/pull/839&gt;
Suggested-by: Timo Stark &lt;t.stark@nginx.com&gt;
Suggested-by: Mark L Wood-Patrick &lt;mwoodpatrick@gmail.com&gt;
Suggested-by: Liam Crilly &lt;liam@nginx.com&gt;
Tested-by: Liam Crilly &lt;liam@nginx.com&gt;
Acked-by: Artem Konev &lt;a.konev@f5.com&gt;
Cc: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Reviewed-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
-  Configuration: added "/config/settings/http/log_route".

   Type: bool
   Default: false

   This adds configurability to the error log.  It allows enabling and
   disabling logs related to how the router performs selection of the
   routes.

-  HTTP: logging request line.

   Log level: [notice]

   The request line is essential to understand which logs correspond to
   which request when reading the logs.

-  HTTP: logging route that's been discarded.

   Log level: [info]

-  HTTP: logging route whose action is selected.

   Log level: [notice]

-  HTTP: logging when "fallback" action is taken.

   Log level: [notice]

Closes: &lt;https://github.com/nginx/unit/issues/758&gt;
Link: &lt;https://github.com/nginx/unit/pull/824&gt;
Link: &lt;https://github.com/nginx/unit/pull/839&gt;
Suggested-by: Timo Stark &lt;t.stark@nginx.com&gt;
Suggested-by: Mark L Wood-Patrick &lt;mwoodpatrick@gmail.com&gt;
Suggested-by: Liam Crilly &lt;liam@nginx.com&gt;
Tested-by: Liam Crilly &lt;liam@nginx.com&gt;
Acked-by: Artem Konev &lt;a.konev@f5.com&gt;
Cc: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Cc: Andrei Zeliankou &lt;zelenkov@nginx.com&gt;
Reviewed-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>HTTP: rewrote while loop as for loop.</title>
<updated>2023-03-21T12:02:38+00:00</updated>
<author>
<name>Alejandro Colomar</name>
<email>alx@nginx.com</email>
</author>
<published>2023-01-10T21:03:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.sigsegv.uk/unit.git/commit/?id=773c341d70d45a501e6ed4adb0fc6d385423a920'/>
<id>773c341d70d45a501e6ed4adb0fc6d385423a920</id>
<content type='text'>
This considerably simplifies the function, and will also help log the
iteration in which we are, which corresponds to the route array element.

Link: &lt;https://github.com/nginx/unit/pull/824&gt;
Link: &lt;https://github.com/nginx/unit/pull/839&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Tested-by: Liam Crilly &lt;liam@nginx.com&gt;
Reviewed-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This considerably simplifies the function, and will also help log the
iteration in which we are, which corresponds to the route array element.

Link: &lt;https://github.com/nginx/unit/pull/824&gt;
Link: &lt;https://github.com/nginx/unit/pull/839&gt;
Reviewed-by: Andrew Clayton &lt;a.clayton@nginx.com&gt;
Tested-by: Liam Crilly &lt;liam@nginx.com&gt;
Reviewed-by: Zhidao Hong &lt;z.hong@f5.com&gt;
Signed-off-by: Alejandro Colomar &lt;alx@nginx.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
