+ struct server_cmdline_parser_params params = {
+ .override = 0,
+ .initialize = 1,
+ .check_required = 0,
+ .check_ambiguity = 0,
+ .print_errors = 1
+ };
+ int afs_socket;
+
+ valid_fd_012();
+ init_random_seed_or_die();
+ /* parse command line options */
+ server_cmdline_parser_ext(argc, argv, &conf, ¶ms);
+ daemon_set_loglevel(conf.loglevel_arg);
+ version_handle_flag("server", conf.version_given);
+ if (conf.help_given || conf.detailed_help_given)
+ print_help_and_die();
+ daemon_drop_privileges_or_die(conf.user_arg, conf.group_arg);
+ /* parse config file, open log and set defaults */
+ parse_config_or_die(0);
+ daemon_log_welcome("server");
+ init_ipc_or_die(); /* init mmd struct and mmd->lock */
+ daemon_set_start_time();
+ init_user_list(user_list_file);
+ /* become daemon */
+ if (conf.daemon_given)
+ daemonize(true /* parent waits for SIGTERM */);
+ PARA_NOTICE_LOG("initializing audio format handlers\n");
+ afh_init();
+
+ /*
+ * Although afs uses its own signal handling we must ignore SIGUSR1
+ * _before_ the afs child process gets born by init_afs() below. It's
+ * racy to do this in the child because the parent might send SIGUSR1
+ * before the child gets a chance to ignore this signal -- only the
+ * good die young.
+ */
+ para_sigaction(SIGUSR1, SIG_IGN);
+ /*
+ * We have to block SIGCHLD before the afs process is being forked off.
+ * Otherwise, para_server does not notice if afs dies before the
+ * SIGCHLD handler has been installed for the parent process by
+ * init_signal_task() below.
+ */
+ para_block_signal(SIGCHLD);
+ PARA_NOTICE_LOG("initializing the audio file selector\n");
+ afs_socket = init_afs(argc, argv);
+ init_signal_task();
+ para_unblock_signal(SIGCHLD);
+ PARA_NOTICE_LOG("initializing virtual streaming system\n");
+ init_vss_task(afs_socket, &sched);
+ init_server_command_task(argc, argv);
+ if (conf.daemon_given)
+ kill(getppid(), SIGTERM);
+ PARA_NOTICE_LOG("server init complete\n");