def configure_signal_handlers(): """Configure signal handlers that among other things allow to dump a stack trace. """ from mysql.fabric.utils import ( catch_signals ) catch_signals(True)
def dispatch(self): """Teardown Fabric Storage System. """ # Configure logging. _configure_logging(self.config, False) # Configure signal handlers. _utils.catch_signals(True) # Configure connections. _configure_connections(self.config) # Drop database and objects. _persistence.teardown()
def dispatch(self): """Setup Fabric Storage System. """ # Configure logging. _configure_logging(self.config, False) # Configure signal handlers. _utils.catch_signals(True) # Configure connections. _configure_connections(self.config) # Create database and objects. _persistence.setup(config=self.config) credentials.check_initial_setup(self.config, _persistence.MySQLPersister())
def dispatch(self, daemonize=False): """Start the Fabric server. """ # Configure logging. _configure_logging(self.config, daemonize) # Configure signal handlers. _utils.catch_signals(True) # Configure connections. _configure_connections(self.config) credentials.check_initial_setup(self.config, _persistence.MySQLPersister(), check_only=True) # Daemonize ourselves. if daemonize: _utils.daemonize() # Start Fabric server. _start(self.options, self.config) _services.ServiceManager().wait()
def dispatch(self, daemonize=False): """Start the Fabric server. """ # Configure logging. _configure_logging(self.config, daemonize) # Configure signal handlers. _utils.catch_signals(True) # Configure connections. _configure_connections(self.config) credentials.check_initial_setup( self.config, _persistence.MySQLPersister(), check_only=True ) # Daemonize ourselves. if daemonize: _utils.daemonize() # Start Fabric server. _start(self.options, self.config) _services.ServiceManager().wait()
def main(): """Start mysqlfabric.py script """ try: # Catch some signals such as SIGUSR1 and SIGINT. catch_signals() # Load information on available commands. find_commands() # Identify exceptions to normal calling conventions, basically # for printing various forms of help. # This require us to first fetch all options before the # (potential) group and command using the default option # parser. PARSER.disable_interspersed_args() options, args = PARSER.parse_args() PARSER.enable_interspersed_args() # Options with side effects, such as --help and --version, # will never come here, so after this all option arguments are # eliminated and the first word in "args" is the the name of a # command group. # At this point, we (should) have at least one non-option word # in the arguments, so we try to get the group and the command # for the group. This might fail, if just a group is provided, # but then the function will print an apropriate message and # exit. group_name, command_name, args = extract_command(args) # If no configuration file was provided, figure out the # location of it based on the installed location of the # script location. if not options.config_file: try: directory = os.path.dirname(__file__) except NameError: if hasattr(sys, 'frozen'): directory = os.path.dirname(sys.executable) else: directory = os.path.abspath( inspect.getfile(inspect.currentframe())) prefix = os.path.realpath(os.path.join(directory, '..')) if os.name == 'posix' and prefix in ('/', '/usr'): config_file = '/etc/mysql/fabric.cfg' else: if hasattr(sys, 'frozen'): prefix = os.path.realpath(directory) config_file = os.path.join(prefix, 'etc', 'mysql', 'fabric.cfg') options.config_file = os.path.normpath(config_file) # Read configuration file config = Config(options.config_file, options.config_params) _config.global_config = copy.copy(config) cmd, cargs = create_command(group_name, command_name, options, args, config) authenticate(group_name, command_name, config, options, args) return fire_command(cmd, *cargs) except (URLError, HTTPError, NoOptionError) as error: if hasattr(error, 'code') and error.code == 400: print "Permission denied." else: print str(error) except KeyboardInterrupt: print "\nAborted due to keyboard interrupt." return 130 except errors.Error as error: print "Error: {0}".format(error) except IOError as error: print "Error reading configuration file: {0}".format(error) return 1