add --conf parameter

This commit is contained in:
arowser 2018-07-11 11:11:09 +08:00 committed by Rusty Russell
parent cf12130627
commit 97118c558e
5 changed files with 24 additions and 6 deletions

View File

@ -2,12 +2,12 @@
.\" Title: lightningd-config
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 06/23/2018
.\" Date: 07/12/2018
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "LIGHTNINGD\-CONFIG" "5" "06/23/2018" "\ \&" "\ \&"
.TH "LIGHTNINGD\-CONFIG" "5" "07/12/2018" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -168,6 +168,11 @@ Set JSON\-RPC socket (or /dev/tty), such as for lightning\-cli(1)\&.
.RS 4
Run in the background, suppress stdout and stderr\&.
.RE
.PP
\fBconf\fR=\fIPATH\fR
.RS 4
Sets configuration file\&. Relative paths will be prefixed by lightning\-dir location\&. (default: config)
.RE
.sp
Lightning node customization options:
.PP

View File

@ -117,6 +117,9 @@ Lightning daemon options:
*daemon*::
Run in the background, suppress stdout and stderr.
*conf*='PATH'::
Sets configuration file. Relative paths will be prefixed by lightning-dir location. (default: config)
Lightning node customization options:
*rgb*='RRGGBB'::

View File

@ -80,6 +80,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
timers_init(&ld->timers, time_mono());
ld->topology = new_topology(ld, ld->log);
ld->daemon = false;
ld->config_filename = NULL;
ld->pidfile = NULL;
ld->ini_autocleaninvoice_cycle = 0;
ld->ini_autocleaninvoice_expiredby = 86400;

View File

@ -80,6 +80,8 @@ struct lightningd {
char *config_dir;
char *rpc_filename;
/* Configuration file name */
char *config_filename;
/* Configuration settings. */
struct config config;

View File

@ -339,6 +339,9 @@ static char *opt_set_locktime(const char *arg, u32 *u)
static void config_register_opts(struct lightningd *ld)
{
opt_register_early_arg("--conf=<file>", opt_set_talstr, NULL,
&ld->config_filename,
"Specify configuration file. Relative paths will be prefixed by lightning-dir location. (default: config)");
opt_register_noarg("--daemon", opt_set_bool, &ld->daemon,
"Run in the background, suppress stdout/stderr");
opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool,
@ -697,10 +700,14 @@ static void opt_parse_from_config(struct lightningd *ld)
char *argv[3];
int i, argc;
if (ld->config_filename != NULL) {
contents = grab_file(ld, ld->config_filename);
} else
contents = grab_file(ld, "config");
/* Doesn't have to exist. */
/* The default config doesn't have to exist, but if the config was
* specified on the command line it has to exist. */
if (!contents) {
if (errno != ENOENT)
if ((errno != ENOENT) || (ld->config_filename != NULL))
fatal("Opening and reading config: %s",
strerror(errno));
/* Now we can set up defaults, since no config file. */