You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Milind Vaidya <ka...@gmail.com> on 2017/01/24 00:36:55 UTC

[users@httpd] Piping logs to a java process : creates multiple processes

>
> I am writing messages to error_log file as well as sending to std out.
>
> The setting looks like
>
>
> ErrorLog  "| /usr/bin/tee -a /var/log/httpd/error_log |  java -cp producer.jar stdin.producer.StdInProducer /CustomProducer/config.json >> /producer_init.log 2>&1"`
>
>
When httpd is started it spawns 2 processes and adds one every one hour,
keeping all alive

Only other thing happening per hour is rotation of error_log file by
logrotate with copytruncate option (which copies the file data and
truncates original file keeping the file descriptor unchanged )

I also tested it with another program with setting as follows which runs
fine, so what am I doing wrong here ?

ErrorLog  "| /usr/bin/tee -a /var/log/httpd/error_log |
/usr/bin/logger -u /tmp/apache_log.socket"

Re: [users@httpd] Piping logs to a java process : creates multiple processes

Posted by Milind Vaidya <ka...@gmail.com>.
I had implemented handling of EOF in the code and it was working fine so
far, until one day I see the java process which is supposed to start every
hour is not doing so. It continues to run. There is no  setting change.
Does that mean somehow logrotate is not sending EOF ?

Does httpd has some error as it hangs on to program or copytruncate is not
sending EOF any more ?

Any idea ?

On Mon, Jan 23, 2017 at 4:41 PM, Eric Covener <co...@gmail.com> wrote:

> On Mon, Jan 23, 2017 at 7:36 PM, Milind Vaidya <ka...@gmail.com> wrote:
> > When httpd is started it spawns 2 processes and adds one every one hour,
> > keeping all alive
>
>
> Your java program needs to exit when stdin returns EOF.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Piping logs to a java process : creates multiple processes

Posted by Milind Vaidya <ka...@gmail.com>.
I am revisiting this. As per the change suggested I modified the program so
that it returns EOF and it was working fine. Until one day, the program
which is supposed to get restarted by apache every hour (that's when log
file rotates), stopped getting restarted. It is not stuck. It is still
processing the things. But it is just that it has been running for many
days with same pid. I wonder if that will cause some problem. I am actually
storing all the events read by this program somewhere else. Then I need to
compare these with the logrotate which is hourly rotating the error_log
file. Here I find few events missing.

Any pointers for debugging this ?


On Mon, Jan 23, 2017 at 4:41 PM, Eric Covener <co...@gmail.com> wrote:

> On Mon, Jan 23, 2017 at 7:36 PM, Milind Vaidya <ka...@gmail.com> wrote:
> > When httpd is started it spawns 2 processes and adds one every one hour,
> > keeping all alive
>
>
> Your java program needs to exit when stdin returns EOF.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Piping logs to a java process : creates multiple processes

Posted by Milind Vaidya <ka...@gmail.com>.
As an extension to this, if I also want to send ssl_error_log to this
program as well, is there any provision to do so ?


This is what I was doing when using manual script to launch the log
consumer.

*tail* *-n0* *-F** /var/log/httpd/error_log /var/log/httpd/ssl_error_log *
*|*

On Mon, Jan 23, 2017 at 5:38 PM, Milind Vaidya <ka...@gmail.com> wrote:

> Thanks for prompt reply Eric.
>
> Adding relevant code resolved, the issue of 2 processes at the beginning.
> Let me wait for logrotate to kick in and see over few hours how it behaves.
>
>
>
> On Mon, Jan 23, 2017 at 4:41 PM, Eric Covener <co...@gmail.com> wrote:
>
>> On Mon, Jan 23, 2017 at 7:36 PM, Milind Vaidya <ka...@gmail.com> wrote:
>> > When httpd is started it spawns 2 processes and adds one every one hour,
>> > keeping all alive
>>
>>
>> Your java program needs to exit when stdin returns EOF.
>>
>> --
>> Eric Covener
>> covener@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

Re: [users@httpd] Piping logs to a java process : creates multiple processes

Posted by Milind Vaidya <ka...@gmail.com>.
Thanks for prompt reply Eric.

Adding relevant code resolved, the issue of 2 processes at the beginning.
Let me wait for logrotate to kick in and see over few hours how it behaves.



On Mon, Jan 23, 2017 at 4:41 PM, Eric Covener <co...@gmail.com> wrote:

> On Mon, Jan 23, 2017 at 7:36 PM, Milind Vaidya <ka...@gmail.com> wrote:
> > When httpd is started it spawns 2 processes and adds one every one hour,
> > keeping all alive
>
>
> Your java program needs to exit when stdin returns EOF.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Piping logs to a java process : creates multiple processes

Posted by Eric Covener <co...@gmail.com>.
On Mon, Jan 23, 2017 at 7:36 PM, Milind Vaidya <ka...@gmail.com> wrote:
> When httpd is started it spawns 2 processes and adds one every one hour,
> keeping all alive


Your java program needs to exit when stdin returns EOF.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org