]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
Enable fork mode under systemd
authorAnbang Wen <anbang@cloudflare.com>
Mon, 18 Jun 2018 22:48:22 +0000 (15:48 -0700)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 7 Sep 2018 17:45:21 +0000 (10:45 -0700)
Although the sockets are still shared, multiple process mode has the
ability to use more CPUs. It should be splitted later.

daemon/main.c

index 5568e34763e50b183be58c0ed6a36a36b729929d..cc3d7dfe9fc1ba83c69f4a535b34529a0eb3f99c 100644 (file)
@@ -416,7 +416,9 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se
 
        /* Notify supervisor. */
 #ifdef HAS_SYSTEMD
-       sd_notify(0, "READY=1");
+       if (leader) {
+               sd_notify(0, "READY=1");
+       }
 #endif
        /* Run event loop */
        uv_run(loop, UV_RUN_DEFAULT);
@@ -610,14 +612,13 @@ int main(int argc, char **argv)
                int fd = SD_LISTEN_FDS_START + i;
                /* when run under systemd supervision, do not use interactive mode */
                args.interactive = false;
-               if (args.forks != 1) {
-                       kr_log_error("[system] when run under systemd-style supervision, "
-                                    "use single-process only (bad: --forks=%d).\n", args.forks);
-                       free_sd_socket_names(socket_names, sd_nsocks);
-                       return EXIT_FAILURE;
-               }
+
                if (!strcasecmp("control",socket_names[i])) {
-                       args.control_fd = fd;
+                       /* only use activated control socket on single
+                        * process mode for now. */
+                       if (args.forks == 1) {
+                               args.control_fd = fd;
+                       }
                } else if (!strcasecmp("tls",socket_names[i])) {
                        array_push(args.tls_fd_set, fd);
                } else {