Skip to content

Commit

Permalink
add --conf parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
arowser authored and rustyrussell committed Jul 15, 2018
1 parent cf12130 commit 97118c5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
9 changes: 7 additions & 2 deletions doc/lightningd-config.5
Original file line number Diff line number Diff line change
Expand Up @@ -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
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion doc/lightningd-config.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Bitcoin control options:

*rescan*='BLOCKS'::
Number of blocks to rescan from the current head, or absolute blockheight
if negative. This is only needed if something goes badly wrong.
if negative. This is only needed if something goes badly wrong.

Lightning daemon options:

Expand All @@ -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'::
Expand Down
1 change: 1 addition & 0 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ struct lightningd {
char *config_dir;
char *rpc_filename;

/* Configuration file name */
char *config_filename;
/* Configuration settings. */
struct config config;

Expand Down
13 changes: 10 additions & 3 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -697,10 +700,14 @@ static void opt_parse_from_config(struct lightningd *ld)
char *argv[3];
int i, argc;

contents = grab_file(ld, "config");
/* Doesn't have to exist. */
if (ld->config_filename != NULL) {
contents = grab_file(ld, ld->config_filename);
} else
contents = grab_file(ld, "config");
/* 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. */
Expand Down

0 comments on commit 97118c5

Please sign in to comment.