From: Loic Dachary <loic@dachary.org>
To: Alexandre Oliva <oliva@gnu.org>, ceph-devel@vger.kernel.org
Subject: Re: [PATCH] daemons: write pid file even when told not to daemonize
Date: Fri, 12 Sep 2014 12:22:32 +0200 [thread overview]
Message-ID: <5412C968.4070207@dachary.org> (raw)
In-Reply-To: <or4mxyuvo4.fsf@free.home>
[-- Attachment #1: Type: text/plain, Size: 2591 bytes --]
Hi Alexandre,
I applied the patch locally and running make check.
Cheers
On 31/07/2014 04:08, Alexandre Oliva wrote:
> systemd wants to run daemons in foreground, but daemons wouldn't write
> out the pid file with -f. Fixed.
>
> Signed-off-by: Alexandre Oliva <oliva@gnu.org>
> ---
> src/ceph_mon.cc | 3 +--
> src/common/config.cc | 2 --
> src/global/global_init.cc | 10 +++++++++-
> 3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc
> index 4e84b4d..14dd6da 100644
> --- a/src/ceph_mon.cc
> +++ b/src/ceph_mon.cc
> @@ -406,8 +406,7 @@ int main(int argc, const char **argv)
> // screwing us over
> Preforker prefork;
> if (!(flags & CINIT_FLAG_NO_DAEMON_ACTIONS)) {
> - if (g_conf->daemonize) {
> - global_init_prefork(g_ceph_context, 0);
> + if (global_init_prefork(g_ceph_context, 0) >= 0) {
> prefork.prefork();
> if (prefork.is_parent()) {
> return prefork.parent_wait();
> diff --git a/src/common/config.cc b/src/common/config.cc
> index 0ee7f58..4e3b6fe 100644
> --- a/src/common/config.cc
> +++ b/src/common/config.cc
> @@ -389,12 +389,10 @@ int md_config_t::parse_argv(std::vector<const char*>& args)
> }
> else if (ceph_argparse_flag(args, i, "--foreground", "-f", (char*)NULL)) {
> set_val_or_die("daemonize", "false");
> - set_val_or_die("pid_file", "");
> }
> else if (ceph_argparse_flag(args, i, "-d", (char*)NULL)) {
> set_val_or_die("daemonize", "false");
> set_val_or_die("log_file", "");
> - set_val_or_die("pid_file", "");
> set_val_or_die("log_to_stderr", "true");
> set_val_or_die("err_to_stderr", "true");
> set_val_or_die("log_to_syslog", "false");
> diff --git a/src/global/global_init.cc b/src/global/global_init.cc
> index 7b20343..f03677c 100644
> --- a/src/global/global_init.cc
> +++ b/src/global/global_init.cc
> @@ -166,8 +166,16 @@ int global_init_prefork(CephContext *cct, int flags)
> if (g_code_env != CODE_ENVIRONMENT_DAEMON)
> return -1;
> const md_config_t *conf = cct->_conf;
> - if (!conf->daemonize)
> + if (!conf->daemonize) {
> + if (atexit(pidfile_remove_void)) {
> + derr << "global_init_daemonize: failed to set pidfile_remove function "
> + << "to run at exit." << dendl;
> + }
> +
> + pidfile_write(g_conf);
> +
> return -1;
> + }
>
> // stop log thread
> g_ceph_context->_log->flush();
>
--
Loïc Dachary, Artisan Logiciel Libre
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
prev parent reply other threads:[~2014-09-12 10:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 2:08 [PATCH] daemons: write pid file even when told not to daemonize Alexandre Oliva
2014-07-31 4:18 ` Loic Dachary
2014-07-31 4:30 ` Sage Weil
2014-08-28 7:35 ` Alexandre Oliva
2014-08-28 8:09 ` Loic Dachary
2014-08-29 6:41 ` Alexandre Oliva
2014-08-29 8:40 ` Loic Dachary
2014-09-04 19:48 ` Alexandre Oliva
2014-09-09 22:21 ` Sage Weil
2014-09-09 22:48 ` Loic Dachary
2014-09-09 22:54 ` Sage Weil
2014-09-12 10:22 ` Loic Dachary [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5412C968.4070207@dachary.org \
--to=loic@dachary.org \
--cc=ceph-devel@vger.kernel.org \
--cc=oliva@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.