Conversation
|
I'm trying to determine if this really gives us anything valuable that we don't already have. I can redirect stdout to a file or syslog very easily with zero lines of code. |
|
I've found that logrotation doesn't work really well with STDOUT redirection, so that's my main angle here. If sidekiq handles its own log file and reopens it on request that would be (at least for me) pretty handy. But you're absolutely right. This is just a proposal, so if you think the added comfort is not worth the introduction of more complexity and responsibility, that's fine too. |
|
Can you update this PR to implement reopening of stdout for log rotation purposes? On 11 Dec 2012, at 22:34, Thorsten Ball notifications@github.com wrote:
|
|
I'd be happy to do it, but what do you mean exactly? Reopening the STDOUT in Sidekiq does not have an impact on a command like this: At least from what I understand and observed, the following happens: when executing the command the STDOUT of Sidekiq gets redirected to a file. Now, let's say a log rotation is happening and But as I said, that's just what I know and observed. Maybe it's possible to get around that. And I'd be happy to do it, but I'd need further explanations on how to do it. I hacked together a quick solution instantiating a new STDOUT-logger on USR2, but the problem persists: output will be written to |
|
@mrnugget You're right, bash is what does the redirection and so it would need to do the rotation. Ugh, bit by bit I'm starting to understand why every Unix daemon has to reimplement this stuff. I'll read through this again tonight and merge it if it looks good. Thanks for helping me understand the issue better! |
|
Sounds good! If there's anything that can be done in a better way, any bugs I'm missing, or something else wrong with the code: let me know! |
|
I've refactored some of the stuff I wrote. I think it does make more sense now and does not include as much duplication as before. Also: since Sidekiq::CLI now has a There's still some stuff going on in the test concerning blowing up with log messages or not, which I don't fully understand. But as the code is now, no test messages and the file logging, as well as STDOUT logging, and the handling of the USR2 signal (when file logging) works. So if there's still something I didn't see, which could be better, please tell! |
|
Update the changelog to give yourself some credit. 🍭 |
|
Great! When this gets merged (I hope the changes in Changes.md won't be a git-merge-conflict-deal-breaker here...) I'll update the Logging-page in the Wiki to reflect the changes. Thanks a lot 👍 |
|
Ugh, merge conflict. |
|
I rebased this branch onto the current master and force pushed it. Now it shouldn't clash with the changes in |
|
Still says it can't be merged. Hmm. |
|
Did another rebase. Somehow some changes didn't get pulled the first time when rebasing. Sorry about that. Does it look better now? |
|
Thanks @mrnugget! |
|
Thank you for merging this! |
|
I believe I'm running into the issue described here where, after logrotation, sidekiq is logging to |
|
@bradical are you sending USR2 to your sidekiq processes? That signals sidekiq to reopen the logfiles and it should log to the correct file afterwards. |
|
To be honest, I'm not sure. I'm using logrotate to rotate files. Perhaps I need to adjust my configuration? |
|
You need to tell logrotate to send the USR2 signal to Sidekiq: Something like that, depending on your configuration. :) Here's an example for Unicorn, which you can adapt to your needs. |
|
Thanks. I'm not familiar with that signal. Will that actually the kill process? Do I need to start it back up in my logrotate config? Also, was something different done in #1008 for this issue? |
|
kill with -USR2 just sends a signal to the process, it won't kill it. If you don't give kill a signal as argument it'll send TERM as signal, which will terminate your process by default. See the manpage of kill: http://linux.die.net/man/1/kill |
|
Thanks for the explanation! I'll give that example Unicorn config a try. |
|
I'm using Sidekiq 2.6.5 and I can't get this to work. I've taken logrotate out of the equation and am doing: However, after the command runs, Sidekiq is still writing to sidekiq.log.bak instead of sidekiq.log. I thought this might be related to #1008 (released in v2.13.0) but that issues just seems to be about closing the old logger and not re-opening the new one. |
|
@bradical I believe you are hitting that bug. Time to upgrade. |
|
Thanks @mperham! Will do. |
While looking for opinions on file logging for Sidekiq I stumbled upon this comment. So I went ahead and gave it a try.
This is a rather simple solution but mostly just a step towards a discussion around this topic.
So, what do you think? Feedback is welcome!