GitHub user danobi opened a pull request:

    https://github.com/apache/trafficserver/pull/274

    TS-306 Enable log rotation for diags.log & traffic.out

    - The commit message contains an architectural overview of this feature
    - 'make test' and './traffic_server -R 1' all pass right now
    - Manual testing yields correct rotational behavior and unchanged behavior 
to access & error logs (eg. squid.log, error.log, etc)
    - Documentation is coming soon

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/danobi/trafficserver log-rotation-squashed

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/274.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #274
    
----
commit 7be0a0d7f44505af2d2aa5e2ce85fb7e8c478a9e
Author: Daniel Xu <danie...@yahoo-inc.com>
Date:   2015-07-13T23:07:30Z

    TS-306 Enable log rotation for diags.log & traffic.out
    
    This feature provides the ability to rotate any log that
    is created by the Diags (including diags.log and
    manager.log) class, as well as traffic.out (the
    output log). These logs can be rotated either by
    time or by size, and both of these options can be
    specified in records.config [see documentation].
    While the feature is relatively small, it required
    a rather large number of internal changes. Therefore,
    the _rest_ of this commit message will be a high
    level architectural overview of the changes
    necessitated by this feature.
    
    The class, BaseLogFile, is added and it is intended
    to be an abstraction for files on disk as well as
    the stdout/stderr stream. BaseLogFile is used by
    both LogFile and Diags to help control individual
    log files. For Diags, each BaseLogFile is created by
    DiagsConfig. DiagsConfig also sets a few more values
    unavailable to Diags. LogFile uses BaseLogFile to
    manage actual files on disk. In some rare cases, LogFile
    also uses BaseLogFile to manage a stdout or stderr
    stream. Most of the functionality in BaseLogFile was
    stripped from LogFile and moved into BaseLogFile.
    
    Originally, traffic.out was just a file whose file
    descriptor was dup2()’d from traffic_cop all the way to
    traffic_server (by way of fork()/exec()). With this
    patch, traffic_cop spawns the traffic_manager process
    with the location of traffic.out specified as flags
    (—-bind_stdout and -—bind_stderr). traffic_manager
    creates two BaseLogFile objects, one for each stdout
    and stderr, both mapped to traffic.out. traffic_manager
    then spawns the traffic_server process with the same
    flags, and traffic_server creates two BaseLogFiles in
    a similar fashion.
    
    As for the actual rotation, traffic_manager checks
    to see if traffic.out needs to be rotated once per
    iteration of traffic_manager’s main loop. As soon
    as traffic_manager rotates traffic.out, SIGUSR2 is
    sent from traffic_manager to traffic_server, and
    traffic_server catches SIGUSR2 and synchronizes its
    own BaseLogFiles with the newly created
    traffic.out file on disk.
    
    For rotation of diags.log, a continuation is
    scheduled every second in traffic_server to see if
    diags.log needs rotation, and then proceeds to
    rotate if necessary. manager.log is checked for
    rotation right after traffic.out is checked for
    rotation in the main loop of traffic_manager.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to