* Server operation.
*/
-static int fork_workers(int forks)
-{
- /* Fork subprocesses if requested */
- while (--forks > 0) {
- int pid = fork();
- if (pid < 0) {
- perror("[system] fork");
- return kr_error(errno);
- }
-
- /* Forked process */
- if (pid == 0) {
- return forks;
- }
- }
- return 0;
-}
-
static void help(int argc, char *argv[])
{
printf("Usage: %s [parameters] [rundir]\n", argv[0]);
}
/** \return exit code for main() */
-static int run_worker(uv_loop_t *loop, bool leader, struct args *args)
+static int run_worker(uv_loop_t *loop, struct args *args)
{
/* Only some kinds of stdin work with uv_pipe_t.
* Otherwise we would abort() from libuv e.g. with </dev/null */
{
memset(args, 0, sizeof(struct args));
/* Zeroed arrays are OK. */
- args->forks = 1;
args->control_fd = -1;
args->interactive = true;
args->quiet = false;
{"addr", required_argument, 0, 'a'},
{"tls", required_argument, 0, 't'},
{"config", required_argument, 0, 'c'},
- {"forks", required_argument, 0, 'f'},
{"noninteractive", no_argument, 0, 'n'},
{"verbose", no_argument, 0, 'v'},
{"quiet", no_argument, 0, 'q'},
kr_require(optarg);
array_push(args->config, optarg);
break;
- case 'f':
- kr_require(optarg);
- args->forks = strtol(optarg, NULL, 10);
- if (args->forks == 1) {
- kr_log_deprecate(SYSTEM, "use --noninteractive instead of --forks=1\n");
- } else {
- kr_log_deprecate(SYSTEM, "support for running multiple --forks will be removed\n");
- }
- if (args->forks <= 0) {
- kr_log_error(SYSTEM, "error '-f' requires a positive"
- " number, not '%s'\n", optarg);
- return EXIT_FAILURE;
- }
- /* fall through */
case 'n':
args->interactive = false;
break;
(long)rlim.rlim_cur);
}
- /* Fork subprocesses if requested */
- int fork_id = fork_workers(the_args->forks);
- if (fork_id < 0) {
- return EXIT_FAILURE;
- }
-
kr_crypto_init();
network_init(uv_default_loop(), TCP_BACKLOG_DEFAULT);
kr_rules_commit(true);
/* Run the event loop */
- ret = run_worker(loop, fork_id == 0, the_args);
+ ret = run_worker(loop, the_args);
cleanup:/* Cleanup. */
network_unregister();
uv_loop_t *loop = uv_default_loop();
the_worker->loop = loop;
- static const int worker_count = 1;
- the_worker->count = worker_count;
-
/* Register table for worker per-request variables */
struct lua_State *L = the_engine->L;
lua_newtable(L);
lua_pushnumber(L, pid);
lua_setfield(L, -2, "pid");
- lua_pushnumber(L, worker_count);
- lua_setfield(L, -2, "count");
char cwd[PATH_MAX];
get_workdir(cwd, sizeof(cwd));
Set the config file with settings for kresd to read instead of reading the
file at the default location (\fIconfig\fR).
.TP
-.B \-f\fI N\fR, \fB\-\-forks=\fI<N>
-This option is deprecated since 5.0.0!
-
-With this option, the daemon is started in non-interactive mode and instead creates a
-UNIX socket in \fIrundir\fR that the operator can connect to for interactive session.
-A number greater than 1 forks the daemon N times, all forks will bind to same addresses
-and the kernel will load-balance between them on Linux with \fISO_REUSEPORT\fR support.
-
-If you want multiple concurrent processes supervised in this way,
-they should be supervised independently (see \fBkresd.systemd(7)\fR).
-.TP
.B \-n\fR, \fB\-\-noninteractive
Daemon will refrain from entering into read-eval-print loop for stdin+stdout.
.TP