From 8a60ce56dce85e443e2dbf845ef867a5962ca0ef Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Sat, 15 Apr 2023 17:17:49 +1100 Subject: [PATCH] Do not initiate trees services. This is done by start command. rename up/down subcommand to start/stop. --- src/lib66/exec/ssexec_help.c | 14 +++++----- src/lib66/exec/ssexec_tree_signal.c | 40 ++++++---------------------- src/lib66/exec/ssexec_tree_wrapper.c | 12 ++++----- 3 files changed, 21 insertions(+), 45 deletions(-) diff --git a/src/lib66/exec/ssexec_help.c b/src/lib66/exec/ssexec_help.c index f214890b..7c6ec02a 100644 --- a/src/lib66/exec/ssexec_help.c +++ b/src/lib66/exec/ssexec_help.c @@ -292,7 +292,7 @@ char const *help_signal = " -r : restart service by sending it a signal(default SIGTERM)\n" ; -char const *usage_tree_wrapper = "66 tree [ -h ] create|admin|remove|enable|disable|current|status|resolve|up|down|unsupervise [<command options>] tree" ; +char const *usage_tree_wrapper = "66 tree [ -h ] create|admin|remove|enable|disable|current|status|resolve|start|stop|unsupervise [<command options>] tree" ; char const *help_tree_wrapper = "\nmain sub tools to manages trees\n" @@ -309,8 +309,8 @@ char const *help_tree_wrapper = " current: mark tree as current\n" " status: display information about tree\n" " resolve: display resolve file of tree\n" -" up: bring up all services from tree\n" -" down: bring down all services from tree\n" +" start: bring up all services from tree\n" +" stop: bring down all services from tree\n" " unsupervise: bring down and unsupervise all services from tree\n" "\n" "Use '66 tree <command> -h' to see command options\n" @@ -428,9 +428,9 @@ char const *help_tree_status = "If no tree name are provided, it display all trees from the system\n" ; -char const *usage_tree_up = "66 tree up [ -h ] [ -f ] tree" ; +char const *usage_tree_start = "66 tree start [ -h ] [ -f ] tree" ; -char const *help_tree_up = +char const *help_tree_start = "\nbring up all enabled services of tree\n" "\n" "options:\n" @@ -440,9 +440,9 @@ char const *help_tree_up = "If no tree name are provided, it bring up all enabled trees from the system\n" ; -char const *usage_tree_down = "66 tree down [ -h ] [ -f ] tree" ; +char const *usage_tree_stop = "66 tree stop [ -h ] [ -f ] tree" ; -char const *help_tree_down = +char const *help_tree_stop = "\nbring down all services of tree\n" "\n" "options:\n" diff --git a/src/lib66/exec/ssexec_tree_signal.c b/src/lib66/exec/ssexec_tree_signal.c index b507fee3..072f8a90 100644 --- a/src/lib66/exec/ssexec_tree_signal.c +++ b/src/lib66/exec/ssexec_tree_signal.c @@ -45,6 +45,7 @@ #include <66/svc.h>//scandir_ok #include <66/utils.h> #include <66/graph.h> +#include <66/state.h> #include <s6/ftrigr.h> #include <s6/ftrigw.h> @@ -144,8 +145,8 @@ static inline unsigned int parse_signal (char const *signal, ssexec_t *info) log_flow() ; static char const *const signal_table[] = { - "up", - "down", + "start", + "stop", "unsupervise", 0 } ; @@ -524,31 +525,6 @@ static int doit(char const *treename, ssexec_t *sinfo, unsigned int what, tain * log_warn_return(LOG_EXIT_ZERO, "You're not allowed to use the tree: ", info.treename.s) ; } - if (!tree_isinitialized(info.base.s, info.treename.s) && !what) { - - if (!what) { - - int nargc = 3 ; - char const *prog = PROG ; - char const *newargv[nargc] ; - unsigned int m = 0 ; - - newargv[m++] = "signal" ; - newargv[m++] = info.treename.s ; - newargv[m++] = 0 ; - - PROG = "init" ; - if (ssexec_init(nargc, newargv, &info)) - log_warnu_return(LOG_EXIT_ZERO, "initiate services of tree: ", info.treename.s) ; - PROG = prog ; - - } else { - - log_warn ("uninitialized tree: ", info.treename.s) ; - goto end ; - } - } - { stralloc sa = STRALLOC_ZERO ; @@ -571,8 +547,8 @@ static int doit(char const *treename, ssexec_t *sinfo, unsigned int what, tain * stralloc_free(&sa) ; } - end: - e = 0 ; + + e = 0 ; err: ssexec_free(&info) ; return e ; @@ -746,7 +722,7 @@ static int async(pidtree_t *apidt, unsigned int i, unsigned int what, ssexec_t * } else { /** do not notify here, the handle will make it for us */ - log_trace("skipping service: ", name, " -- already ", what ? "down" : "up") ; + log_trace("skipping tree: ", name, " -- already ", what ? "down" : "up") ; } @@ -790,7 +766,7 @@ static int waitit(pidtree_t *apidt, unsigned int what, graph_t *graph, tain *dea } - for (pos = 0 ; pos < napid ; pos++) { + for (pos = 0 ; pos < napid ; pos++) { pid = fork() ; @@ -903,7 +879,7 @@ int ssexec_tree_signal(int argc, char const *const *argv, ssexec_t *info) if ((svc_scandir_ok(info->scandir.s)) <= 0) log_die(LOG_EXIT_SYS,"scandir: ", info->scandir.s," is not running") ; - graph_build_tree(&graph, info->base.s, !info->treename.len ? E_RESOLVE_TREE_MASTER_ENABLED : E_RESOLVE_TREE_CONTENTS) ; + graph_build_tree(&graph, info->base.s, !info->treename.len ? E_RESOLVE_TREE_MASTER_ENABLED : E_RESOLVE_TREE_MASTER_CONTENTS) ; if (!graph.mlen) log_die(LOG_EXIT_USER, "trees selection is not created -- creates at least one tree") ; diff --git a/src/lib66/exec/ssexec_tree_wrapper.c b/src/lib66/exec/ssexec_tree_wrapper.c index eada7b90..fa74c249 100644 --- a/src/lib66/exec/ssexec_tree_wrapper.c +++ b/src/lib66/exec/ssexec_tree_wrapper.c @@ -139,19 +139,19 @@ int ssexec_tree_wrapper(int argc, char const *const *argv, ssexec_t *info) argc-- ; argv++ ; - } else if (!strcmp(argv[1], "up")) { + } else if (!strcmp(argv[1], "start")) { info->prog = PROG ; - info->help = help_tree_up ; - info->usage = usage_tree_up ; + info->help = help_tree_start ; + info->usage = usage_tree_start ; func = &ssexec_tree_signal ; ctl++ ; - } else if (!strcmp(argv[1], "down")) { + } else if (!strcmp(argv[1], "stop")) { info->prog = PROG ; - info->help = help_tree_down ; - info->usage = usage_tree_down ; + info->help = help_tree_stop ; + info->usage = usage_tree_stop ; func = &ssexec_tree_signal ; ctl++ ; -- GitLab