summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/generic-main.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-05-02 13:18:39 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-05-06 13:57:09 +1000
commitbbaa3ac16e14b1f386d70d14f16d0164d163017e (patch)
tree3d0929402f9f2175fe00e1f12a348eafcb136c12 /ui/ncurses/generic-main.c
parent1949b1f0f990c7ab171339e20731fe6b17c92d8f (diff)
downloadtalos-petitboot-bbaa3ac16e14b1f386d70d14f16d0164d163017e.tar.gz
talos-petitboot-bbaa3ac16e14b1f386d70d14f16d0164d163017e.zip
ui/ncurses: Start UI before connected to server
If petitboot-nc starts before the discover server it will try to connect for a short while waiting for the server to appear. However in some scenarios the server can take longer than expected to come up, for example if the kernel is compiled with modules and the system has many disks, and the process will timeout and exit before the server is ready. The UI does not appear during this time so it can appear as if Petitboot failed to start at all. Change the default behaviour to start the UI first, and then wait for the server to appear. The UI will not timeout in this mode. The "--timeout" option is added to start with the old behaviour. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'ui/ncurses/generic-main.c')
-rw-r--r--ui/ncurses/generic-main.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ui/ncurses/generic-main.c b/ui/ncurses/generic-main.c
index 27744d4..7062796 100644
--- a/ui/ncurses/generic-main.c
+++ b/ui/ncurses/generic-main.c
@@ -49,8 +49,8 @@ static void print_usage(void)
{
print_version();
printf(
-"%s: petitboot-nc [-h, --help] [-l, --log log-file]\n"
-" [-s, --start-daemon] [-v, --verbose] [-V, --version]\n",
+"%s: petitboot-nc [-h, --help] [-l, --log log-file] [-s, --start-daemon]\n"
+" [-t, --timeout] [-v, --verbose] [-V, --version]\n",
_("Usage"));
}
@@ -68,6 +68,7 @@ struct opts {
enum opt_value show_help;
const char *log_file;
enum opt_value start_daemon;
+ enum opt_value timeout;
enum opt_value verbose;
enum opt_value show_version;
};
@@ -82,11 +83,12 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, 'l'},
{"start-daemon", no_argument, NULL, 's'},
+ {"timeout", no_argument, NULL, 't'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{ NULL, 0, NULL, 0},
};
- static const char short_options[] = "dhl:svV";
+ static const char short_options[] = "dhl:stvV";
static const struct opts default_values = { 0 };
*opts = default_values;
@@ -108,6 +110,9 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
case 's':
opts->start_daemon = opt_yes;
break;
+ case 't':
+ opts->timeout = opt_yes;
+ break;
case 'v':
opts->verbose = opt_yes;
break;
@@ -244,7 +249,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
- cui = cui_init(NULL, NULL, opts.start_daemon);
+ cui = cui_init(NULL, NULL, opts.start_daemon, opts.timeout);
if (!cui)
return EXIT_FAILURE;
OpenPOWER on IntegriCloud