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

fix oneshot logger destination

parent 63dfc47d
No related branches found
No related tags found
No related merge requests found
Pipeline #15561 failed
......@@ -89,5 +89,6 @@ extern uint32_t compute_status(resolve_wrapper_t_ref wres, ssexec_t *info) ;
extern uint32_t compute_scan_dir(resolve_wrapper_t_ref wres, ssexec_t *info) ;
extern uint32_t compute_state_dir(resolve_wrapper_t_ref wres, ssexec_t *info, char const *folder) ;
extern uint32_t compute_pipe_service(resolve_wrapper_t_ref wres, ssexec_t *info, char const *name) ;
extern uint32_t compute_log_dir(resolve_wrapper_t_ref wres, resolve_service_t *res) ;
#endif
......@@ -32,7 +32,7 @@
#define FAKELEN strlen(run)
#endif
static uint32_t compute_log_dir(resolve_wrapper_t_ref wres, resolve_service_t *res)
uint32_t compute_log_dir(resolve_wrapper_t_ref wres, resolve_service_t *res)
{
log_flow() ;
......@@ -249,20 +249,10 @@ void parse_append_logger(struct resolve_hash_s **hres, resolve_service_t *res, s
{
log_flow() ;
char *name = res->sa.s + res->name ;
char *logname = res->sa.s + res->logger.name ;
struct resolve_hash_s *hash ;
resolve_service_t lres = RESOLVE_SERVICE_ZERO ;
resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, res) ;
size_t namelen = strlen(name) ;
char logname[namelen + SS_LOG_SUFFIX_LEN + 1] ;
auto_strings(logname, name, SS_LOG_SUFFIX) ;
res->logger.name = resolve_add_string(wres, logname) ;
res->logger.destination = compute_log_dir(wres, res) ;
res->logger.execute.run.runas = res->logger.execute.run.runas ? resolve_add_string(wres, res->sa.s + res->logger.execute.run.runas) : resolve_add_string(wres, SS_LOGGER_RUNNER) ;
hash = hash_search(hres, logname) ;
if (hash == NULL && res->type == TYPE_CLASSIC) {
......@@ -270,14 +260,14 @@ void parse_append_logger(struct resolve_hash_s **hres, resolve_service_t *res, s
if (res->dependencies.ndepends) {
char buf[strlen(res->sa.s + res->dependencies.depends) + 1 + strlen(res->sa.s + res->logger.name) + 1] ;
auto_strings(buf, res->sa.s + res->dependencies.depends, " ", res->sa.s + res->logger.name) ;
char buf[strlen(res->sa.s + res->dependencies.depends) + 1 + strlen(logname) + 1] ;
auto_strings(buf, res->sa.s + res->dependencies.depends, " ", logname) ;
res->dependencies.depends = resolve_add_string(wres, buf) ;
} else {
res->dependencies.depends = resolve_add_string(wres, res->sa.s + res->logger.name) ;
res->dependencies.depends = resolve_add_string(wres, logname) ;
}
res->dependencies.ndepends++ ;
......@@ -297,4 +287,4 @@ void parse_append_logger(struct resolve_hash_s **hres, resolve_service_t *res, s
}
free(wres) ;
}
\ No newline at end of file
}
......@@ -258,6 +258,21 @@ void parse_compute_resolve(resolve_service_t *res, ssexec_t *info)
/* oneshotd */
res->live.oneshotddir = compute_pipe_service(wres, info, SS_ONESHOTD) ;
if (res->logger.want && res->type != TYPE_MODULE && !res->inns) {
char *name = res->sa.s + res->name ;
size_t namelen = strlen(name) ;
char logname[namelen + SS_LOG_SUFFIX_LEN + 1] ;
auto_strings(logname, name, SS_LOG_SUFFIX) ;
res->logger.name = resolve_add_string(wres, logname) ;
res->logger.destination = compute_log_dir(wres, res) ;
res->logger.execute.run.runas = res->logger.execute.run.runas ? resolve_add_string(wres, res->sa.s + res->logger.execute.run.runas) : resolve_add_string(wres, SS_LOGGER_RUNNER) ;
}
if (res->type == TYPE_ONESHOT || res->type == TYPE_CLASSIC) {
// {run,up}/{run,up}.user script
......
......@@ -116,7 +116,7 @@ void parse_rename_interdependences(resolve_service_t *res, char const *prefix, s
struct resolve_hash_s *c, *tmp ;
stralloc sa = STRALLOC_ZERO ;
resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, res) ;
resolve_wrapper_t_ref wres = 0 ;
HASH_ITER(hh, *hres, c, tmp) {
......@@ -129,9 +129,16 @@ void parse_rename_interdependences(resolve_service_t *res, char const *prefix, s
size_t namelen = strlen(c->res.sa.s + c->res.name) ;
char logname[namelen + SS_LOG_SUFFIX_LEN + 1] ;
wres = resolve_set_struct(DATA_SERVICE, &c->res) ;
auto_strings(logname, c->res.sa.s + c->res.name, SS_LOG_SUFFIX) ;
c->res.logger.name = resolve_add_string(wres, logname) ;
c->res.logger.destination = compute_log_dir(wres, res) ;
c->res.logger.execute.run.runas = c->res.logger.execute.run.runas ? resolve_add_string(wres, c->res.sa.s + c->res.logger.execute.run.runas) : resolve_add_string(wres, SS_LOGGER_RUNNER) ;
parse_append_logger(hres, &c->res, info) ;
if (c->res.type == TYPE_CLASSIC) {
......@@ -145,8 +152,11 @@ void parse_rename_interdependences(resolve_service_t *res, char const *prefix, s
if (!sastr_add_string(&sa, c->res.sa.s + c->res.name))
log_die_nomem("stralloc") ;
}
free(wres) ;
}
wres = resolve_set_struct(DATA_SERVICE, res) ;
res->dependencies.contents = parse_compute_list(wres, &sa, &res->dependencies.ncontents, 0) ;
stralloc_free(&sa) ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment