def run(self): signal.signal(signal.SIGINT, self.stop) signal.signal(signal.SIGQUIT, self.stop) signal.signal(signal.SIGTERM, self.stop) self.exiting = False self.logger = log.get_logger('Server') # switch over to the correct user as soon as possible if self.options.set_user is not None: if not setuser(self.options.set_user): self.logger.error('failed to switch to user %s' % self.options.set_user) sys.exit(1) if self.options.daemonize: # ensure connection pool forks from daemon pool.close_connections() with storage.LoaderStorage.fork_wrapper(): daemonize(self.options.log_path) pool.recreate_pool() # record the fact that we've started successfully self.servers = Servers() self.servers.ping() if self.options.num_workers > WORKER_WARN_THRESHOLD and not self.options.force_workers: if not cli_utils.confirm( 'Are you sure you want to start %d workers? This is potentially dangerous.' % self.options.num_workers, default=False): print 'Exiting.' sys.exit(1) self.logger.debug('Starting worker pool') self.pool = WorkerPool(num_workers=self.options.num_workers) print 'MemSQL Loader Server running' loader_db_name = storage.MEMSQL_LOADER_DB has_valid_loader_db_conn = False while not self.exiting: try: if bootstrap.check_bootstrapped(): has_valid_loader_db_conn = True self.pool.poll() self.servers.ping() time.sleep(1) else: if has_valid_loader_db_conn: self.logger.warn( 'The %s database is unreachable or not ready; stopping worker pool', loader_db_name) self.pool.stop() has_valid_loader_db_conn = False time.sleep(5) except KeyboardInterrupt: break self.stop()
def run(self): prompt = 'Are you sure you want to delete the MemSQL Loader database?\nThe database contains queued, running, and finished jobs.' if not cli_utils.confirm(prompt, default=False): print 'Exiting.' sys.exit(1) LoaderStorage.drop_database() print 'MemSQL Loader database deleted.'
def run(self): signal.signal(signal.SIGINT, self.stop) signal.signal(signal.SIGQUIT, self.stop) signal.signal(signal.SIGTERM, self.stop) self.exiting = False self.logger = log.get_logger('Server') # switch over to the correct user as soon as possible if self.options.set_user is not None: if not setuser(self.options.set_user): self.logger.error('failed to switch to user %s' % self.options.set_user) sys.exit(1) if self.options.daemonize: # ensure connection pool forks from daemon pool.close_connections() with storage.LoaderStorage.fork_wrapper(): daemonize(self.options.log_path) pool.recreate_pool() # record the fact that we've started successfully self.servers = Servers() self.servers.ping() if self.options.num_workers > WORKER_WARN_THRESHOLD and not self.options.force_workers: if not cli_utils.confirm('Are you sure you want to start %d workers? This is potentially dangerous.' % self.options.num_workers, default=False): print 'Exiting.' sys.exit(1) self.logger.debug('Starting worker pool') self.pool = WorkerPool(num_workers=self.options.num_workers) print 'MemSQL Loader Server running' loader_db_name = storage.MEMSQL_LOADER_DB has_valid_loader_db_conn = False while not self.exiting: try: if bootstrap.check_bootstrapped(): has_valid_loader_db_conn = True self.pool.poll() self.servers.ping() time.sleep(1) else: if has_valid_loader_db_conn: self.logger.warn('The %s database is unreachable or not ready; stopping worker pool', loader_db_name) self.pool.stop() has_valid_loader_db_conn = False time.sleep(5) except KeyboardInterrupt: break self.stop()
def run(self): if not self.options.force: if servers.is_server_running(): print 'Please stop any currently-running servers with stop-server before deleting the MemSQL Loader database.' sys.exit(1) prompt = 'Are you sure you want to delete the MemSQL Loader database?\nThe database contains queued, running, and finished jobs.' if not cli_utils.confirm(prompt, default=False): print 'Exiting.' sys.exit(1) LoaderStorage.drop_database() print 'MemSQL Loader database deleted.'