static char *configfile = NULL;
static int foreground = 0;
+static int inetd_request = 0;
static workq_t dir_workq; /* queue of work from Director */
CLIENT *me; /* my resource */
static void usage()
{
fprintf(stderr, _(
-"\nVersion: " VERSION " (" DATE ")\n\n"
+"\nVersion: " VERSION " (" BDATE ")\n\n"
"Usage: filed [-f -s] [-c config_file] [-d debug_level] [config_file]\n"
" -c <file> use <file> as configuration file\n"
" -dnn set debug level to nn\n"
" -f run in foreground (for debugging)\n"
+" -i inetd request\n"
" -s no signals (for debugging)\n"
" -t test configuration file and exit\n"
" -? print this message.\n"
memset(&last_job, 0, sizeof(last_job));
- while ((ch = getopt(argc, argv, "c:d:fst?")) != -1) {
+ while ((ch = getopt(argc, argv, "c:d:fist?")) != -1) {
switch (ch) {
case 'c': /* configuration file */
if (configfile != NULL) {
foreground = TRUE;
break;
+ case 'i':
+ inetd_request = TRUE;
+ break;
case 's':
no_signals = TRUE;
break;
terminate_filed(0);
}
- if (!foreground) {
+ if (!foreground &&!inetd_request) {
daemon_start();
init_stack_dump(); /* set new pid */
}
+ /* Maximum 1 daemon at a time */
create_pid_file(me->pid_directory, "bacula-fd", me->FDport);
#ifdef BOMB
start_watchdog(); /* start watchdog thread */
- /* Become server, and handle requests */
- Dmsg1(10, "filed: listening on port %d\n", me->FDport);
- bnet_thread_server(me->FDport, 10, &dir_workq, handle_client_request);
+ if (inetd_request) {
+ /* Socket is on fd 0 */
+ BSOCK *bs = init_bsock(NULL, 0, "client", "unknown client", me->FDport);
+ handle_client_request((void *)bs);
+ } else {
+ /* Become server, and handle requests */
+ Dmsg1(10, "filed: listening on port %d\n", me->FDport);
+ bnet_thread_server(me->FDaddr, me->FDport, me->MaxConcurrentJobs,
+ &dir_workq, handle_client_request);
+ }
+ term_msg();
exit(0); /* should never get here */
}