Git Product home page Git Product logo

Comments (3)

bmc avatar bmc commented on August 15, 2024

I understand what you're describing. Logrotate is clearly just unlinking and relinking the file, so the inode isn't changing. The open file descriptor daemonize passes to the daemonized server refers (in the kernel) to that inode; the file name is irrelevant.

Yes, I can see where this can be a problem.

However, there's no easy way to have daemonize close the file descriptor and reopen it, to prevent this problem. The main problem is that daemonize, itself, is no longer running at this point. When it was fired up, it overlaid itself (via exec(2)) with the program you really want to run.

People typically handle this kind of problem in a few different ways.

  • Apache, for instance, lets you pipe output into a program, and there are programs out there that'll do log rotation for you, based on the piped-in data. I could extend daemonize to permit this kind of thing, I suppose (i.e., allow -o to specify a pipe to a command). I can see the benefit, but there's a creeping featurism feeling to that approach. daemonize is small and simple; I'd hate to make it needlessly complicated.
  • Another one I've seen on Unix systems is to shut down the server, roll its log, then restart the server. This second option might work for you; unless something goes wrong, the server won't be down more than a second or two.

I'm open to suggestions. I'd rather not bloat daemonize, if I can help it, but this is an understandbly annoying problem.

from daemonize.

frankfarmer avatar frankfarmer commented on August 15, 2024

Thanks for the quick response!

That's more or less what I expected the state of things would be. I just wanted to make sure there wasn't already an appropriate daemonize feature I should have been using. We'll come up with some sort of workaround -- probably a wrapper between daemonize and our scripts that punts output to a log, and reopens the log file when it receives a HUP.

from daemonize.

jhpedemonte avatar jhpedemonte commented on August 15, 2024

I've been using the copytruncate property of logrotate, which copies the existing file and then truncates it to 0 size. Working well so far.

from daemonize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.