Skip to content
Snippets Groups Projects
Commit e46e2f84 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

do not start a service not already running

parent df60d2f3
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <oblibs/log.h> #include <oblibs/log.h>
#include <oblibs/types.h> #include <oblibs/types.h>
#include <oblibs/graph.h> #include <oblibs/graph.h>
#include <oblibs/sastr.h>
#include <skalibs/sgetopt.h> #include <skalibs/sgetopt.h>
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
#include <66/svc.h> #include <66/svc.h>
#include <66/sanitize.h> #include <66/sanitize.h>
#include <66/service.h> #include <66/service.h>
#include <66/constants.h>
#include <stdio.h> #include <stdio.h>
...@@ -38,12 +40,13 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info) ...@@ -38,12 +40,13 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
uint32_t flag = 0 ; uint32_t flag = 0 ;
uint8_t siglen = 0 ; uint8_t siglen = 0 ;
graph_t graph = GRAPH_ZERO ; graph_t graph = GRAPH_ZERO ;
stralloc sa = STRALLOC_ZERO ;
unsigned int areslen = 0, list[SS_MAX_SERVICE], visit[SS_MAX_SERVICE], nservice = 0, n = 0 ; unsigned int areslen = 0, list[SS_MAX_SERVICE], visit[SS_MAX_SERVICE], nservice = 0, n = 0 ;
resolve_service_t ares[SS_MAX_SERVICE] ; resolve_service_t ares[SS_MAX_SERVICE] ;
char atree[SS_MAX_TREENAME + 1] ; char atree[SS_MAX_TREENAME + 1] ;
FLAGS_SET(flag, STATE_FLAGS_TOPROPAGATE|STATE_FLAGS_TOINIT|STATE_FLAGS_WANTUP) ; FLAGS_SET(flag, STATE_FLAGS_TOPROPAGATE|STATE_FLAGS_TOPARSE|STATE_FLAGS_WANTUP) ;
{ {
subgetopt l = SUBGETOPT_ZERO ; subgetopt l = SUBGETOPT_ZERO ;
...@@ -87,7 +90,7 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info) ...@@ -87,7 +90,7 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
if (!r) { if (!r) {
/** nothing to do */ /** nothing to do */
log_warn(argv[n], " is not parsed -- try to start it first") ; log_warn(argv[n], " is not parsed -- try to parse it first") ;
return 0 ; return 0 ;
} }
...@@ -135,6 +138,10 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info) ...@@ -135,6 +138,10 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
} }
} }
} }
/** keep list of already running service */
char const *exclude[4] = { SS_FDHOLDER, SS_ONESHOTD, SS_SVSCAN_LOG, 0 } ;
if (!sastr_dir_get(&sa, info->scandir.s, exclude, S_IFDIR))
log_dieusys(LOG_EXIT_SYS, "get list of running services") ;
{ {
/** stop service and unsupervise it */ /** stop service and unsupervise it */
...@@ -163,7 +170,6 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info) ...@@ -163,7 +170,6 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
{ {
/** start service */ /** start service */
unsigned int m = 0 ; unsigned int m = 0 ;
int nargc = 1 + nservice + siglen ;
char const *newargv[nargc] ; char const *newargv[nargc] ;
newargv[m++] = "start" ; newargv[m++] = "start" ;
...@@ -172,17 +178,18 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info) ...@@ -172,17 +178,18 @@ int ssexec_reconfigure(int argc, char const *const *argv, ssexec_t *info)
for (n = 0 ; n < nservice ; n++) { for (n = 0 ; n < nservice ; n++) {
char *name = graph.data.s + genalloc_s(graph_hash_t,&graph.hash)[list[n]].vertex ; char *name = graph.data.s + genalloc_s(graph_hash_t,&graph.hash)[list[n]].vertex ;
newargv[m++] = name ; if (sastr_cmp(&sa, name) >= 0)
newargv[m++] = name ;
} }
newargv[m++] = 0 ; newargv[m++] = 0 ;
e = ssexec_start(nargc, newargv, info) ; e = ssexec_start(m - 1, newargv, info) ;
} }
freed: freed:
stralloc_free(&sa) ;
service_resolve_array_free(ares, areslen) ; service_resolve_array_free(ares, areslen) ;
graph_free_all(&graph) ; graph_free_all(&graph) ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment