def remote_transaction_mysql(conn_info): MYSQL_FORWARDED_PORT = 33000 utils.kill_listening_processes(MYSQL_FORWARDED_PORT) if utils.can_connect(MYSQL_FORWARDED_PORT): raise Exception('MySQL tunnel port (%s) is not ' 'available' % MYSQL_FORWARDED_PORT) ssh_command_line = utils.ssh_command_line( self.config, extra_opts='-N -L {forwarded_port}:localhost:3306'.format( forwarded_port=MYSQL_FORWARDED_PORT)) log.debug('ssh command line for tunnel: %s', ssh_command_line) p = subprocess.Popen(ssh_command_line, shell=True) log.info('Waiting a bit for the tunnel to establish...') time.sleep(3) remote_conn_info = db_backends.ConnectionInfo( self.config.remote_conn_string) remote_conn_info.data['port'] = MYSQL_FORWARDED_PORT remote_conn_info.data['host'] = '127.0.0.1' yield remote_conn_info p.kill()
def init_db(self): utils.kill_listening_processes(self.env.c.port) self.drop_db() self._create_db() self.start_daemon() self.stop_daemon() log.info('db initialized')
def stopdaemon(self): """Stop Synthese daemon""" self.daemon.stop() # TODO: should use the HTTP method to stop the daemon once it works. ports = [self.config.port] if self.config.wsgi_proxy: ports.append(self.config.wsgi_proxy_port) for port in ports: utils.kill_listening_processes(port)
def kill_existing(cls, env, kill_proxy=True): ports_to_check = [env.c.port] if kill_proxy and env.c.wsgi_proxy: ports_to_check.append(env.c.wsgi_proxy_port) for port in ports_to_check: utils.kill_listening_processes(port) if utils.can_connect(port): raise DaemonException( 'Error, something is already listening on port %s' % port)
def serve_forever(env, project): utils.kill_listening_processes(env.c.wsgi_proxy_port) if utils.can_connect(env.c.wsgi_proxy_port): raise Exception("Error, something is already listening on port %s", env.c.wsgi_proxy_port) proxy = start(env, project) log.info("Proxy running, press ctrl-c to stop") try: while True: time.sleep(10) except KeyboardInterrupt: print "^C" log.info("Stopping proxy") stop()
def serve_forever(env, project): utils.kill_listening_processes(env.c.wsgi_proxy_port) if utils.can_connect(env.c.wsgi_proxy_port): raise Exception('Error, something is already listening on port %s', env.c.wsgi_proxy_port) proxy = start(env, project) log.info('Proxy running, press ctrl-c to stop') try: while True: time.sleep(10) except KeyboardInterrupt: print '^C' log.info('Stopping proxy') stop()