Add verbose prints when spawn server fails to spawn. (#9305)
Markos Fountoulakis committed
Jun 9, 2020 at 14:26 UTC
6a9a465497c760e0793d73ee1a579725fae9e75a
1 file changed
+15
-2
spawn/spawn.c
+15
-2
@@ -196,10 +196,19 @@ int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t
196
int ret;
197
#define SPAWN_SERVER_DESCRIPTORS (3)
198
uv_stdio_container_t stdio[SPAWN_SERVER_DESCRIPTORS];
199
+ struct passwd *passwd = NULL;
200
+ char *user = NULL;
201
+
202
+ passwd = getpwuid(getuid());
203
+ user = (passwd && passwd->pw_name) ? passwd->pw_name : "";
204
205
exepath_size = sizeof(exepath);
206
ret = uv_exepath(exepath, &exepath_size);
202
- assert(ret == 0);
207
+ if (0 != ret) {
208
+ error("uv_exepath(\"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
209
+ uv_strerror(ret));
210
+ fatal("Cannot start netdata without the spawn server.");
211
+ }
212
213
exepath[exepath_size] = '\0';
214
args[0] = exepath;
@@ -221,7 +230,11 @@ int create_spawn_server(uv_loop_t *loop, uv_pipe_t *spawn_channel, uv_process_t
230
stdio[2].data.fd = 2 /* UV_STDERR_FD */;
231
232
ret = uv_spawn(loop, process, &options); /* execute the netdata binary again as the netdata user */
224
- assert(ret == 0);
233
+ if (0 != ret) {
234
+ error("uv_spawn (process: \"%s\", %u) (user: %s) failed (%s).", exepath, (unsigned)exepath_size, user,
235
+ uv_strerror(ret));
236
+ fatal("Cannot start netdata without the spawn server.");
237
+ }
238
239
return ret;
240
}