summaryrefslogtreecommitdiffstats
path: root/spawn
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2020-06-09 14:26:08 +0300
committerGitHub <noreply@github.com>2020-06-09 14:26:08 +0300
commit6a9a465497c760e0793d73ee1a579725fae9e75a (patch)
treea2b33c27a6d147b85dcd3fac02e85b98931281de /spawn
parent58dcbce3e99f0e444f27bc57a6758bf244f2a5b8 (diff)
Add verbose prints when spawn server fails to spawn. (#9305)
Diffstat (limited to 'spawn')
-rw-r--r--spawn/spawn.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/spawn/spawn.c b/spawn/spawn.c
index 8d57adc344..8b3afcf3b2 100644
--- a/spawn/spawn.c
+++ b/spawn/spawn.c
@@ -196,10 +196,19 @@ int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t
int ret;
#define SPAWN_SERVER_DESCRIPTORS (3)
uv_stdio_container_t stdio[SPAWN_SERVER_DESCRIPTORS];
+ struct passwd *passwd = NULL;
+ char *user = NULL;
+
+ passwd = getpwuid(getuid());
+ user = (passwd && passwd->pw_name) ? passwd->pw_name : "";
exepath_size = sizeof(exepath);
ret = uv_exepath(exepath, &exepath_size);
- assert(ret == 0);
+ if (0 != ret) {
+ error("uv_exepath(\"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
+ uv_strerror(ret));
+ fatal("Cannot start netdata without the spawn server.");
+ }
exepath[exepath_size] = '\0';
args[0] = exepath;
@@ -221,7 +230,11 @@ int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t
stdio[2].data.fd = 2 /* UV_STDERR_FD */;
ret = uv_spawn(loop, process, &options); /* execute the netdata binary again as the netdata user */
- assert(ret == 0);
+ if (0 != ret) {
+ error("uv_spawn (process: \"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
+ uv_strerror(ret));
+ fatal("Cannot start netdata without the spawn server.");
+ }
return ret;
}