Bug 19610 - Make koha-common.logrotate use copytruncate
Summary: Make koha-common.logrotate use copytruncate
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Josef Moravec
URL:
Keywords:
Depends on: 20234
Blocks: 17468
  Show dependency treegraph
 
Reported: 2017-11-12 03:44 UTC by Tomás Cohen Arazi
Modified: 2019-10-14 19:56 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 19610: Make koha-common.logroate use copytruncate (2.08 KB, patch)
2018-02-17 15:07 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 19610: Make koha-common.logroate use copytruncate (2.11 KB, patch)
2018-02-20 12:08 UTC, Hugo Agud
Details | Diff | Splinter Review
Bug 19610: Make koha-common.logroate use copytruncate (2.16 KB, patch)
2018-02-21 17:43 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 19610: Make koha-common.logrotate use copytruncate (2.16 KB, patch)
2018-02-21 17:43 UTC, Josef Moravec
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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!