Bug 19610

Summary: Make koha-common.logrotate use copytruncate
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: PackagingAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: normal    
Priority: P5 - low CC: hagud, josef.moravec, liz, mirko, mtj
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 20234    
Bug Blocks: 17468    
Attachments: Bug 19610: Make koha-common.logroate use copytruncate
Bug 19610: Make koha-common.logroate use copytruncate
Bug 19610: Make koha-common.logroate use copytruncate
Bug 19610: Make koha-common.logrotate use copytruncate

Description Tomás Cohen Arazi 2017-11-12 03:44:20 UTC
Both bug 15713 and bug 16138 introduce service restarts when log rotation happens. This is done:
- Stop services (plack and zebra)
- Rotate the log file
- Start services (plack and zebra)

This can be avoided by using the 'copytruncate' directive in the logrotate configuration [1]

[1] Search for 'copytruncate' here https://linux.die.net/man/8/logrotate
Comment 1 Tomás Cohen Arazi 2018-02-17 15:07:02 UTC
Created attachment 71884 [details] [review]
Bug 19610: Make koha-common.logroate use copytruncate

This patch makes logrotate use the **copytruncate** directive, removing
the need to stop the Zebra and Plack servers on log rotation.

To test:
- Run:
  $ misc4dev/cp_debian_files.pl
- Edit the new /etc/logrotate.d/koha-common file changing 'weekly' for
'hourly'. This is to ease testing.
- Run:
  $ sudo ls -l /var/log/koha/kohadev
- Open a second terminal on your kohadevbox. On it...
- Run:
  $ sudo logrotate /etc/logrotate.d/koha-common
- Run:
  $ sudo ls -l /var/log/koha/kohadev
=> SUCCESS: Files got rotated! (i.e. files ending in .1 are created, the
        sizes make sense (.1 have contents, the ones without numbering
            probably zeroed <- it will depend on what's happening with
            your devbox in between).
- Play with your Koha, do some searches too:
=> SUCCESS: You have access to your Koha, searches work. i.e.:
     - Apache handled the log rotation operation
     - Plack handled the log rotation operation
     - Zebra handled the log rotation operation
- Sign off :-D!

Sponsored-by: Orex Digital
Comment 2 Hugo Agud 2018-02-20 12:08:22 UTC
Created attachment 71997 [details] [review]
Bug 19610: Make koha-common.logroate use copytruncate

This patch makes logrotate use the **copytruncate** directive, removing
the need to stop the Zebra and Plack servers on log rotation.

To test:
- Run:
  $ misc4dev/cp_debian_files.pl
- Edit the new /etc/logrotate.d/koha-common file changing 'weekly' for
'hourly'. This is to ease testing.
- Run:
  $ sudo ls -l /var/log/koha/kohadev
- Open a second terminal on your kohadevbox. On it...
- Run:
  $ sudo logrotate /etc/logrotate.d/koha-common
- Run:
  $ sudo ls -l /var/log/koha/kohadev
=> SUCCESS: Files got rotated! (i.e. files ending in .1 are created, the
        sizes make sense (.1 have contents, the ones without numbering
            probably zeroed <- it will depend on what's happening with
            your devbox in between).
- Play with your Koha, do some searches too:
=> SUCCESS: You have access to your Koha, searches work. i.e.:
     - Apache handled the log rotation operation
     - Plack handled the log rotation operation
     - Zebra handled the log rotation operation
- Sign off :-D!

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud hagud@orex.es
Comment 3 Mirko Tietgen 2018-02-20 12:12:59 UTC
Hi Hugo, please set your credentials in your development system. Your patch says

> Signed-off-by: Your Full Name <your_email>

You can find some information here: https://wiki.koha-community.org/wiki/Version_Control_Using_Git#Getting_Started_with_Git
Comment 4 Hugo Agud 2018-02-20 12:19:09 UTC
fixed.. thanks!
Comment 5 Josef Moravec 2018-02-21 17:43:01 UTC
Created attachment 72040 [details] [review]
Bug 19610: Make koha-common.logroate use copytruncate

This patch makes logrotate use the **copytruncate** directive, removing
the need to stop the Zebra and Plack servers on log rotation.

To test:
- Run:
  $ misc4dev/cp_debian_files.pl
- Edit the new /etc/logrotate.d/koha-common file changing 'weekly' for
'hourly'. This is to ease testing.
- Run:
  $ sudo ls -l /var/log/koha/kohadev
- Open a second terminal on your kohadevbox. On it...
- Run:
  $ sudo logrotate /etc/logrotate.d/koha-common
- Run:
  $ sudo ls -l /var/log/koha/kohadev
=> SUCCESS: Files got rotated! (i.e. files ending in .1 are created, the
        sizes make sense (.1 have contents, the ones without numbering
            probably zeroed <- it will depend on what's happening with
            your devbox in between).
- Play with your Koha, do some searches too:
=> SUCCESS: You have access to your Koha, searches work. i.e.:
     - Apache handled the log rotation operation
     - Plack handled the log rotation operation
     - Zebra handled the log rotation operation
- Sign off :-D!

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud hagud@orex.es

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 6 Josef Moravec 2018-02-21 17:43:56 UTC
Created attachment 72042 [details] [review]
Bug 19610: Make koha-common.logrotate use copytruncate

This patch makes logrotate use the **copytruncate** directive, removing
the need to stop the Zebra and Plack servers on log rotation.

To test:
- Run:
  $ misc4dev/cp_debian_files.pl
- Edit the new /etc/logrotate.d/koha-common file changing 'weekly' for
'hourly'. This is to ease testing.
- Run:
  $ sudo ls -l /var/log/koha/kohadev
- Open a second terminal on your kohadevbox. On it...
- Run:
  $ sudo logrotate /etc/logrotate.d/koha-common
- Run:
  $ sudo ls -l /var/log/koha/kohadev
=> SUCCESS: Files got rotated! (i.e. files ending in .1 are created, the
        sizes make sense (.1 have contents, the ones without numbering
            probably zeroed <- it will depend on what's happening with
            your devbox in between).
- Play with your Koha, do some searches too:
=> SUCCESS: You have access to your Koha, searches work. i.e.:
     - Apache handled the log rotation operation
     - Plack handled the log rotation operation
     - Zebra handled the log rotation operation
- Sign off :-D!

Sponsored-by: Orex Digital

Signed-off-by: Hugo Agud hagud@orex.es

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 7 Josef Moravec 2018-02-21 17:44:51 UTC
Just a not: cp_debian_files.pl does not handle koha-common.logrotate
Comment 8 Jonathan Druart 2018-02-27 18:59:20 UTC
Pushed to master for 18.05, thanks to everybody involved!