many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation plus additions
- that are listed in the file LICENSE.
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
{
int ch;
JCR *jcr;
- int no_signals = FALSE;
- int test_config = FALSE;
+ bool no_signals = false;
+ bool test_config = false;
char *uid = NULL;
char *gid = NULL;
if (debug_level <= 0) {
debug_level = 1;
}
- Dmsg1(0, "Debug level = %d\n", debug_level);
+ Dmsg1(10, "Debug level = %d\n", debug_level);
break;
case 'f': /* run in foreground */
break;
case 's': /* turn off signals */
- no_signals = TRUE;
+ no_signals = true;
break;
case 't': /* test config */
- test_config = TRUE;
+ test_config = true;
break;
case 'u': /* set uid */
Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
}
+ if (!test_config) { /* we don't need to do this block in test mode */
+ if (background) {
+ daemon_start();
+ init_stack_dump(); /* grab new pid */
+ }
+
+ /* Create pid must come after we are a daemon -- so we have our final pid */
+ create_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
+ read_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
+ }
+
drop(uid, gid); /* reduce privileges if requested */
if (!check_catalog()) {
FDConnectTimeout = (int)director->FDConnectTimeout;
SDConnectTimeout = (int)director->SDConnectTimeout;
- if (background) {
- daemon_start();
- init_stack_dump(); /* grab new pid */
- }
-
- /* Create pid must come after we are a daemon -- so we have our final pid */
- create_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
- read_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
-
#if !defined(HAVE_WIN32)
signal(SIGHUP, reload_config);
return 0;
}
+/*
+ * This allows the message handler to operate on the database
+ * by using a pointer to this function. The pointer is
+ * needed because the other daemons do not have access
+ * to the database. If the pointer is
+ * not defined (other daemons), then writing the database
+ * is disabled.
+ */
static void dir_sql_query(JCR *jcr, const char *cmd)
{
if (!jcr || !jcr->db) {
static bool already_here = false;
if (already_here) { /* avoid recursive temination problems */
+ bmicrosleep(2, 0); /* yield */
exit(1);
}
already_here = true;
generate_daemon_event(NULL, "Exit");
write_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
delete_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs));
-// signal(SIGCHLD, SIG_IGN); /* don't worry about children now */
term_scheduler();
term_job_server();
if (runjob) {
ok = parse_config(configfile, 0, M_ERROR); /* no exit on error */
Dmsg0(100, "Reloaded config file\n");
- if (!ok || !check_resources()) {
+ if (!ok || !check_resources() || !check_catalog()) {
rtable = find_free_reload_table_entry(); /* save new, bad table */
if (rtable < 0) {
Jmsg(NULL, M_ERROR, 0, _("Please correct configuration file: %s\n"), configfile);
set_working_directory(director->working_directory);
FDConnectTimeout = director->FDConnectTimeout;
SDConnectTimeout = director->SDConnectTimeout;
- Dmsg0(0, "Director's configuration file reread.\n");
+ Dmsg0(10, "Director's configuration file reread.\n");
/* Now release saved resources, if no jobs using the resources */
if (njobs == 0) {