17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
22
#include <drizzled/configmake.h>
23
23
#include <drizzled/atomics.h>
76
76
#include <drizzled/tztime.h>
77
77
#include <drizzled/unireg.h>
78
78
#include <plugin/myisam/myisam.h>
79
#include <drizzled/typelib.h>
80
#include <drizzled/visibility.h>
80
#include "drizzled/visibility.h"
82
82
#include <google/protobuf/stubs/common.h>
136
136
#include <sys/fpu.h>
139
#include <drizzled/internal/my_pthread.h> // For thr_setconcurency()
140
#include <drizzled/constrained_value.h>
139
#include "drizzled/internal/my_pthread.h" // For thr_setconcurency()
140
#include "drizzled/constrained_value.h"
142
142
#include <drizzled/gettext.h>
308
308
fs::path system_config_dir(SYSCONFDIR);
311
char system_time_zone[30];
312
char *default_tz_name;
313
DRIZZLED_API char glob_hostname[FN_REFLEN];
311
315
char *opt_tc_log_file;
312
316
const key_map key_map_empty(0);
313
317
key_map key_map_full(0); // Will be initialized later
358
362
DRIZZLED_API size_t transaction_message_threshold;
364
/* Function declarations */
365
bool drizzle_rm_tmp_tables();
360
367
static void drizzle_init_variables(void);
361
368
static void get_options();
362
369
static void fix_paths();
367
374
fs::path base_plugin_dir(PKGPLUGINDIR);
369
po::options_description config_options(_("Config File Options"));
370
po::options_description long_options(_("Kernel Options"));
371
po::options_description plugin_load_options(_("Plugin Loading Options"));
372
po::options_description plugin_options(_("Plugin Options"));
373
po::options_description initial_options(_("Config and Plugin Loading"));
374
po::options_description full_options(_("Kernel and Plugin Loading and Plugin"));
376
po::options_description config_options("Config File Options");
377
po::options_description long_options("Kernel Options");
378
po::options_description plugin_load_options("Plugin Loading Options");
379
po::options_description plugin_options("Plugin Options");
380
po::options_description initial_options("Config and Plugin Loading");
381
po::options_description full_options("Kernel and Plugin Loading and Plugin");
375
382
vector<string> unknown_options;
376
383
vector<string> defaults_file_list;
377
384
po::variables_map vm;
387
std::string &getGlobHostname()
389
static std::string glob_hostname("localhost");
390
return glob_hostname;
393
void setServerHostname(const std::string &hostname)
395
getGlobHostname()= hostname;
399
const std::string &getServerHostname()
401
return getGlobHostname();
404
392
/****************************************************************************
405
393
** Code to end drizzled
666
654
static void find_plugin_dir(string progname)
668
fs::path full_progname(fs::system_complete(progname));
670
fs::path progdir(full_progname.parent_path());
671
if (progdir.filename() == ".libs")
673
progdir= progdir.parent_path();
676
if (fs::exists(progdir / "drizzled.lo") || fs::exists(progdir / "drizzled.o"))
656
if (progname[0] != FN_LIBCHAR)
658
/* We have a relative path and need to find the absolute */
659
char working_dir[FN_REFLEN];
660
char *working_dir_ptr= working_dir;
661
working_dir_ptr= getcwd(working_dir_ptr, FN_REFLEN);
662
string new_path(working_dir);
663
if (*(new_path.end()-1) != '/')
664
new_path.push_back('/');
665
if (progname[0] == '.' && progname[1] == '/')
666
new_path.append(progname.substr(2));
668
new_path.append(progname);
669
progname.swap(new_path);
672
/* Now, trim off the exe name */
673
string progdir(progname.substr(0, progname.rfind(FN_LIBCHAR)+1));
674
if (progdir.rfind(".libs/") != string::npos)
676
progdir.assign(progdir.substr(0, progdir.rfind(".libs/")));
678
string testlofile(progdir);
679
testlofile.append("drizzled.lo");
680
string testofile(progdir);
681
testofile.append("drizzled.o");
682
struct stat testfile_stat;
683
if (not (stat(testlofile.c_str(), &testfile_stat) && stat(testofile.c_str(), &testfile_stat)))
678
685
/* We are in a source dir! Plugin dir is ../plugin/.libs */
679
base_plugin_dir= progdir.parent_path();
686
size_t last_libchar_pos= progdir.rfind(FN_LIBCHAR,progdir.size()-2)+1;
687
base_plugin_dir= progdir.substr(0,last_libchar_pos);
680
688
base_plugin_dir /= "plugin";
681
689
base_plugin_dir /= ".libs";
1091
1099
drizzle_init_variables();
1093
1101
find_plugin_dir(argv[0]);
1104
localtime_r(&server_start_time,&tm_tmp);
1105
strncpy(system_time_zone, tzname[tm_tmp.tm_isdst != 0 ? 1 : 0],
1106
sizeof(system_time_zone)-1);
1096
1110
We set SYSTEM time zone as reasonable default and
1097
1111
also for failure of my_tz_init() and bootstrap mode.
1101
1115
global_system_variables.time_zone= my_tz_SYSTEM;
1103
char ret_hostname[FN_REFLEN];
1104
if (gethostname(ret_hostname,sizeof(ret_hostname)) < 0)
1117
if (gethostname(glob_hostname,sizeof(glob_hostname)) < 0)
1106
errmsg_printf(error::WARN,
1107
_("gethostname failed, using '%s' as hostname"),
1108
getServerHostname().c_str());
1119
strncpy(glob_hostname, STRING_WITH_LEN("localhost"));
1120
errmsg_printf(error::WARN, _("gethostname failed, using '%s' as hostname"),
1109
1122
pid_file= "drizzle";
1113
setServerHostname(ret_hostname);
1114
pid_file= getServerHostname();
1126
pid_file= glob_hostname;
1116
1128
pid_file.replace_extension(".pid");
1305
1317
po::value<uint64_t>(&global_system_variables.tmp_table_size)->default_value(16*1024*1024L)->notifier(&check_limits_tmp_table_size),
1306
1318
_("If an internal in-memory temporary table exceeds this size, Drizzle will"
1307
1319
" automatically convert it to an on-disk MyISAM table."))
1308
("verbose", po::value<std::string>()->default_value(error::verbose_string())->notifier(&error::check_verbosity),
1309
_("The stack size for each thread."))
1312
1322
full_options.add(long_options);