[
https://issues.apache.org/jira/browse/DAEMON-213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16863166#comment-16863166
]
Bill Stewart edited comment on DAEMON-213 at 6/13/19 3:33 PM:
--------------------------------------------------------------
NSSM - [https://nssm.cc/] claims this capability - but see
[https://nssm.cc/usage#io_technical] as it might not be worth the risk. Details
from there:
I/O redirected; online rotation enabled
This case is by far the most complex of the three and is thus necessarily most
at risk of something going wrong, potentially resulting in the loss of output
from the application.
nssm first calls CreateFile() just as in the previous case. It then calls
CreatePipe() to open an anonymous pipe. The reading end of the pipe and the
handle to the output file are passed to a new thread which does the actual
writing. The writing end of the pipe is duplicated with DuplicateHandle() for
passing to CreateProcess(). Thus the application will run with an open handle
to one end of the pipe and nssm will run with a handle to the other end of the
pipe and a handle to the output file.
The writing thread runs a simple loop wherein it reads data from the pipe, ie
the application's output, into a buffer with ReadFile() then writes the
contents of that buffer to the output file with WriteFile(). If the file hits
the configured size limit the thread will write up to the next newline, close
its output handle, rotate the file and open a new handle to continue writing to
the new file.
When nssm receives an on-demand rotation request it will set a flag which
instructs the writing thread to perform a rotation after the next ReadFile()
call completes, regardless of the file size. Because ReadFile() blocks
execution until something is read, nssm won't actually get round to rotating
the file until the application produces the next line of output.
nssm doesn't know whether the output from the application will be Unicode or
ANSI, so prior to writing the first data to the file, or to rotating, it calls
IsTextUnicode() to try to determine the text encoding that's in use. If it
(looks like it) is Unicode, nssm writes a UTF-16 byte-order marker to the
beginning of the new file so that it will be read correctly when opened with a
text editor.
If both stdout and stderr are redirected, and to separate files, nssm will
spawn a writing thread for each. nssm will deal with an application which
writes stdout in Unicode and stderr in ANSI - or vice versa - if you are
unfortunate (or evil) enough to run one.
It should be clear from the above that there are a number of pitfalls to online
rotation. nssm will try to deal gracefully with any problems during the I/O
process but to be safe you should consider not using online rotation unless
your output is so voluminous that you have no choice.
was (Author: bstewart):
This doesn't seem to be impossible - NSSM it seems can do this somehow; see -
[https://nssm.cc/usage#online_rotation] for details.
> procun log rotation support
> ---------------------------
>
> Key: DAEMON-213
> URL: https://issues.apache.org/jira/browse/DAEMON-213
> Project: Commons Daemon
> Issue Type: Improvement
> Components: Procrun
> Affects Versions: 1.0.4, 1.0.5, 1.0.6
> Environment: os: winxp
> Reporter: viola.lu
> Priority: Minor
>
> currently, procun doesn't support log rotation. Should add an option
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)