Comments (3)
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.
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.
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)
- Support for out-of-tree builds is broken. HOT 1
- Question about the daemonize result HOT 4
- -o and -e flags are not working HOT 4
- Too many -E environment variables? HOT 1
- CPU usage spikes to 100% HOT 7
- Environment variables HOT 2
- [PATCH] CFLAGS and LDFLAGS not used when building HOT 3
- [PATCH] Missing includes in daemonize.c
- how to run the command "proxy --port 42780" as a daemon? HOT 1
- Problem daemonizing script from systemd service HOT 1
- Missing tag for 1.7.8 HOT 1
- Autoreconf will fail when calling autoheader on Linux system HOT 9
- allow -o to specify a pipe to a [rotatelogs] command HOT 7
- What does daemonize do that this demo doesn't?
- Daemonize skipping python commands HOT 1
- REQUEST: Support directing daemon output to syslog
- Failure to cross-compile for Android/AArch64 HOT 5
- breaks if /proc/self/fd/[012] already closed
- -p creates a zero-length file
- Open null_fd as O_RDWR
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from daemonize.