lightningd: Defer creating the PID until we actually want to start

This was causing `--help` to fail if we already had a `lightningd` running
with the same `--lightning-dir`.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2019-08-05 19:13:48 +02:00 committed by ZmnSCPxj, ZmnSCPxj jxPCSmnZ
parent e2f9a410f4
commit 820b52207e
1 changed files with 4 additions and 4 deletions

View File

@ -672,10 +672,6 @@ int main(int argc, char *argv[])
* say --daemonize. */
handle_early_opts(ld, argc, argv);
/*~ Now create the PID file: this errors out if there's already a
* daemon running, so we call before doing almost anything else. */
pidfile_create(ld);
/*~ Initialize all the plugins we just registered, so they can
* do their thing and tell us about themselves (including
* options registration). */
@ -684,6 +680,10 @@ int main(int argc, char *argv[])
/*~ Handle options and config; move to .lightningd (--lightning-dir) */
handle_opts(ld, argc, argv);
/*~ Now create the PID file: this errors out if there's already a
* daemon running, so we call before doing almost anything else. */
pidfile_create(ld);
/*~ Make sure we can reach the subdaemons, and versions match. */
test_subdaemons(ld);