diff options
Diffstat (limited to 'src/arm/gnunet-arm.c')
-rw-r--r-- | src/arm/gnunet-arm.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 3396a4dbe..fcbff2331 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -54,6 +54,11 @@ static int delete; | |||
54 | static int quiet; | 54 | static int quiet; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Set if we should print all services, including stopped ones. | ||
58 | */ | ||
59 | static int show_all; | ||
60 | |||
61 | /** | ||
57 | * Monitor ARM activity. | 62 | * Monitor ARM activity. |
58 | */ | 63 | */ |
59 | static int monitor; | 64 | static int monitor; |
@@ -508,13 +513,13 @@ term_callback(void *cls, | |||
508 | * @param cls closure (unused) | 513 | * @param cls closure (unused) |
509 | * @param rs request status (success, failure, etc.) | 514 | * @param rs request status (success, failure, etc.) |
510 | * @param count number of services in the list | 515 | * @param count number of services in the list |
511 | * @param list list of services that are running | 516 | * @param list list of services managed by arm |
512 | */ | 517 | */ |
513 | static void | 518 | static void |
514 | list_callback(void *cls, | 519 | list_callback(void *cls, |
515 | enum GNUNET_ARM_RequestStatus rs, | 520 | enum GNUNET_ARM_RequestStatus rs, |
516 | unsigned int count, | 521 | unsigned int count, |
517 | const char *const *list) | 522 | const struct GNUNET_ARM_ServiceInfo *list) |
518 | { | 523 | { |
519 | (void)cls; | 524 | (void)cls; |
520 | op = NULL; | 525 | op = NULL; |
@@ -540,9 +545,41 @@ list_callback(void *cls, | |||
540 | return; | 545 | return; |
541 | } | 546 | } |
542 | if (!quiet) | 547 | if (!quiet) |
543 | fprintf(stdout, "%s", _("Running services:\n")); | 548 | { |
549 | if (show_all) | ||
550 | fprintf(stdout, "%s", _("All services:\n")); | ||
551 | else | ||
552 | fprintf(stdout, "%s", _("Services (excluding stopped services):\n")); | ||
553 | } | ||
544 | for (unsigned int i = 0; i < count; i++) | 554 | for (unsigned int i = 0; i < count; i++) |
545 | fprintf(stdout, "%s\n", list[i]); | 555 | { |
556 | struct GNUNET_TIME_Relative restart_in; | ||
557 | switch (list[i].status) | ||
558 | { | ||
559 | case GNUNET_ARM_SERVICE_STATUS_STOPPED: | ||
560 | if (show_all) | ||
561 | fprintf(stdout, "%s (binary='%s', status=stopped)\n", list[i].name, list[i].binary); | ||
562 | break; | ||
563 | case GNUNET_ARM_SERVICE_STATUS_FAILED: | ||
564 | restart_in = GNUNET_TIME_absolute_get_remaining (list[i].restart_at); | ||
565 | fprintf(stdout, "%s (binary='%s', status=failed, exit_status=%d, restart_delay='%s')\n", | ||
566 | list[i].name, | ||
567 | list[i].binary, | ||
568 | list[i].last_exit_status, | ||
569 | GNUNET_STRINGS_relative_time_to_string (restart_in, GNUNET_YES)); | ||
570 | break; | ||
571 | case GNUNET_ARM_SERVICE_STATUS_FINISHED: | ||
572 | fprintf(stdout, "%s (binary='%s', status=finished)\n", list[i].name, list[i].binary); | ||
573 | break; | ||
574 | case GNUNET_ARM_SERVICE_STATUS_STARTED: | ||
575 | fprintf(stdout, "%s (binary='%s', status=started)\n", list[i].name, list[i].binary); | ||
576 | break; | ||
577 | default: | ||
578 | fprintf(stdout, "%s (binary='%s', status=unknown)\n", list[i].name, list[i].binary); | ||
579 | break; | ||
580 | |||
581 | } | ||
582 | } | ||
546 | al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL); | 583 | al_task = GNUNET_SCHEDULER_add_now(&action_loop, NULL); |
547 | } | 584 | } |
548 | 585 | ||
@@ -652,7 +689,7 @@ action_loop(void *cls) | |||
652 | static void | 689 | static void |
653 | srv_status(void *cls, | 690 | srv_status(void *cls, |
654 | const char *service, | 691 | const char *service, |
655 | enum GNUNET_ARM_ServiceStatus status) | 692 | enum GNUNET_ARM_ServiceMonitorStatus status) |
656 | { | 693 | { |
657 | const char *msg; | 694 | const char *msg; |
658 | 695 | ||
@@ -773,6 +810,10 @@ main(int argc, char *const *argv) | |||
773 | "SERVICE", | 810 | "SERVICE", |
774 | gettext_noop("stop a particular service"), | 811 | gettext_noop("stop a particular service"), |
775 | &term), | 812 | &term), |
813 | GNUNET_GETOPT_option_flag('a', | ||
814 | "all", | ||
815 | gettext_noop("also show stopped services (used with -I)"), | ||
816 | &show_all), | ||
776 | GNUNET_GETOPT_option_flag('s', | 817 | GNUNET_GETOPT_option_flag('s', |
777 | "start", | 818 | "start", |
778 | gettext_noop( | 819 | gettext_noop( |