"/etc/init.d/td-agent start" starting duplicate instances of td-agent

603 views
Skip to first unread message

Michael Allman

unread,
Apr 3, 2013, 3:45:21 PM4/3/13
to flu...@googlegroups.com
Hello,

I installed td-agent 1.1.11-1 on an Ubuntu 12.04 instance using the instructions on http://docs.fluentd.org/articles/install-by-deb. When I start td-agent with "sudo /etc/init.d/td-agent start", it starts two instances of td-agent. From "ps aux | grep td-agent" I get:

td-agent 19682  0.0  0.1  98872 13472 ?        Sl   19:39   0:00 /usr/lib/fluent/ruby/bin/ruby /usr/sbin/td-agent --daemon /var/run/td-agent/td-agent.pid --log /var/log/td-agent/td-agent.log
td-agent 19685  0.0  0.2 109720 19112 ?        Sl   19:39   0:00 /usr/lib/fluent/ruby/bin/ruby /usr/sbin/td-agent --daemon /var/run/td-agent/td-agent.pid --log /var/log/td-agent/td-agent.log

/var/run/td-agent/td-agent.pid contains "19682" which suggests that pid 19685 is a rogue process. Is this a bug in the init script? If the init script is supposed to start two instances of td-agent, shouldn't they use different pid and log files?

Cheers,

Michael

Sadayuki Furuhashi

unread,
Apr 3, 2013, 3:51:01 PM4/3/13
to flu...@googlegroups.com
Hello Michael,

One Fluentd instance consists of two processes.
The first one (pid 19682) is a supervisor process which monitors the child process (pid 19685) using a pipe.
The supervisor restarts the child process if heartbeats from the pipe stopped.

Fluentd runs with many kinds of plugins and some of them could be unstable. The supervisor reduces risk of
unexpected crash.

--
Sadayuki Furuhashi
http://fluentd.org http://msgpack.org
twitter:@frsyuki
> --
> You received this message because you are subscribed to the Google Groups "Fluentd Google Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fluentd+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Michael Allman

unread,
Apr 3, 2013, 3:58:28 PM4/3/13
to flu...@googlegroups.com
Hi Sadayuki,

Thanks for your reply. I'm still a little confused. What's confusing me is that it looks like the child process is writing its pid and log to the same place as the parent process. How do they keep from stepping on each other's pid and log files? Do both processes actually write to the log file, or just one?

Cheers,

Michael
> You received this message because you are subscribed to a topic in the Google Groups "Fluentd Google Group" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/fluentd/Ltf_wfRFBCo/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to fluentd+u...@googlegroups.com.

Sadayuki Furuhashi

unread,
Apr 3, 2013, 4:07:08 PM4/3/13
to flu...@googlegroups.com
Hi Michael,

pid file:
The child process doesn't write its pid to a file. The init script sends signals only to the parent process to and the
parent process sends signals to the child process.

log file:
Both of them write logs into the same file. The point is that they open logs in append-mode.
When they get USR1 signal, both of them re-opens the log file in append-mode again.

--
Sadayuki Furuhashi
http://fluentd.org http://msgpack.org
twitter:@frsyuki

Michael Allman

unread,
Apr 3, 2013, 4:11:15 PM4/3/13
to flu...@googlegroups.com
Okay, that clears things up for me. Thank you!

If I may make a suggestion, since the child process does not write to a pid file, don't start it with "/var/run/td-agent/td-agent.pid" as part of its command line. That might make it more obvious to new users that the init script is behaving correctly. :)

Cheers,

Michael

Kazuki Ohta

unread,
Apr 3, 2013, 5:37:49 PM4/3/13
to flu...@googlegroups.com
Michael,

I'm a maintainer of td-agent packaging scripts. So how should I change the scirpt? > https://github.com/treasure-data/td-agent

Actually nginx has similar model (root vs workers) and it launches multiple workers at '/etc/init.d/nginx start'.

Just curious what confused you, and want to fix it.

Thanks -K
--------------------------------------------------
Kazuki Ohta: http://kzk9.net/

Michael Allman

unread,
Apr 3, 2013, 7:13:34 PM4/3/13
to flu...@googlegroups.com
Hi Kazuki,

What confused me is that the child process is started with a flag that looks like it writes its pid to a file which the parent process is using. Both processes have "/var/run/td-agent/td-agent.pid" in their command line, but only the parent process actually writes to it. Also, the child process's command line is identical to the parent process's, so they look like duplicate processes.

Cheers,

Michael

Richard Bradley

unread,
Jun 14, 2016, 10:52:51 AM6/14/16
to Fluentd Google Group, mic...@eclipse.io
I had the same confusion -- I saw two `td-agent` processes running on my machine, with identical command line arguments shown by "ps". I assumed that there was a bug somewhere which was causing the service to incorrectly run twice.

Luckily this thread is the first search result for "td-agent two instances".

If it's easy to do so, I would suggest changing the init.d script so that the child and supervisor processes have different command line arguments.

HTH


Rich
Reply all
Reply to author
Forward
0 new messages