logrotate script does not reload logs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
The logrotate script installed by sudo pm2 logrotate -u <user> per http://pm2.keymetrics.io/docs/usage/log-management/#setting-up-a-native-logrotate will create log files that are not written to (they stay at 0 bytes).
What did you expect to happen?
I expect that log files created by logrotate can be written to by pm2.
Environment info
Operating System: Ubuntu 14.04.4
Pm2 version: 1.1.3
Node version: 0.10.45
Shell: bash
Steps to reproduce
sudo pm2 logrotate -u <user>sudo logrotate -f /etc/logrotate.d/pm2-<user>ls -la ~/.pm2/logs- Observe that the new log files stay at 0 bytes in size.
pm2 reloadLogsls -la ~/.pm2/logs- Observe that the new log files are now logged to.
What have you tried?
- The solution by @sominlee74 in https://github.com/Unitech/pm2/issues/1469#issuecomment-215672049 fixed the issue entirely.
I believe that the logrotate script that gets generated just needs to have a couple more things added to it. Adding su <user> <user> and
postrotate
su -c "pm2 reloadLogs" - <user>
endscript
fixed the issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the implementation behind sudo pm2 logrotate -u <user> and the generated /etc/logrotate.d/pm2-<user> script. Reproduce the issue with sudo logrotate -f, then verify that rotated logs receive new output without running pm2 reloadLogs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, javascript, nodejs
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100