From mboxrd@z Thu Jan 1 00:00:00 1970 From: Loic Dachary Subject: Re: [PATCH] daemons: write pid file even when told not to daemonize Date: Fri, 12 Sep 2014 12:22:32 +0200 Message-ID: <5412C968.4070207@dachary.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CftSW3pnV5DEFSOOf3kKfaDPlSKuOqooM" Return-path: Received: from mail2.dachary.org ([91.121.57.175]:50613 "EHLO smtp.dmail.dachary.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753428AbaILKW4 (ORCPT ); Fri, 12 Sep 2014 06:22:56 -0400 In-Reply-To: Sender: ceph-devel-owner@vger.kernel.org List-ID: To: Alexandre Oliva , ceph-devel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CftSW3pnV5DEFSOOf3kKfaDPlSKuOqooM Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Alexandre Oliva > --- > src/ceph_mon.cc | 3 +-- > src/common/config.cc | 2 -- > src/global/global_init.cc | 10 +++++++++- > 3 files changed, 10 insertions(+), 5 deletions(-) >=20 > 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) >=3D 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& 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 flag= s) > if (g_code_env !=3D CODE_ENVIRONMENT_DAEMON) > return -1; > const md_config_t *conf =3D cct->_conf; > - if (!conf->daemonize) > + if (!conf->daemonize) { > + if (atexit(pidfile_remove_void)) { > + derr << "global_init_daemonize: failed to set pidfile_remove fun= ction " > + << "to run at exit." << dendl; > + } > + > + pidfile_write(g_conf); > + > return -1; > + } > =20 > // stop log thread > g_ceph_context->_log->flush(); >=20 --=20 Lo=EFc Dachary, Artisan Logiciel Libre --CftSW3pnV5DEFSOOf3kKfaDPlSKuOqooM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlQSyWgACgkQ8dLMyEl6F21eVQCdHVovelOauAx7btLHFqzZpn5Z NGIAoInbw9xweCKk8hCT3tAh9BRUROdl =PTdf -----END PGP SIGNATURE----- --CftSW3pnV5DEFSOOf3kKfaDPlSKuOqooM--