error = False except: http_port += 1 if not disable_upnp: application.setup_upnp_port_mappings(http_port, p2p_port) else: print "Disabling upnp setup" locallogger.info("Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port)) print "Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port) if disable_open_browser == "0": open_default_webbrowser('http://%s:%s' % (http_ip, http_port)) try: signal.signal(signal.SIGTERM, application.shutdown) except ValueError: # not the main thread pass if not tornado.ioloop.IOLoop.instance(): ioloop.install() else: try: tornado.ioloop.IOLoop.instance().start() except Exception as e: pass
def attempt_browser_open(ob_ctx): if not ob_ctx.disable_open_browser: open_default_webbrowser( 'http://%s:%s' % (ob_ctx.http_ip, ob_ctx.http_port))
def start_node(my_market_ip, my_market_port, http_ip, http_port, log_file, market_id, bm_user=None, bm_pass=None, bm_port=None, seed_peers=[], seed_mode=0, dev_mode=False, log_level=None, database='db/ob.db', disable_upnp=False, disable_open_browser=False): logging.basicConfig(level=int(log_level), format='%(asctime)s - %(name)s - \ %(levelname)s - %(message)s', filename=log_file) locallogger = logging.getLogger('[%s] %s' % (market_id, 'root')) handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=50, backupCount=0) locallogger.addHandler(handler) application = MarketApplication(my_market_ip, my_market_port, market_id, bm_user, bm_pass, bm_port, seed_peers, seed_mode, dev_mode, database) error = True p2p_port = 12345 if http_port == -1: http_port = get_random_free_tcp_port(8889, 8988) while error: try: application.listen(http_port, http_ip) error = False except: http_port += 1 if not disable_upnp: application.setup_upnp_port_mappings(http_port, p2p_port) else: print "Disabling upnp setup" locallogger.info("Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port)) print "Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port) if disable_open_browser == "0": open_default_webbrowser('http://%s:%s' % (http_ip, http_port)) try: signal.signal(signal.SIGTERM, application.shutdown) except ValueError: # not the main thread pass if not tornado.ioloop.IOLoop.instance(): ioloop.install() else: tornado.ioloop.IOLoop.instance().start()
def start_node(my_market_ip, my_market_port, http_ip, http_port, log_file, market_id, bm_user=None, bm_pass=None, bm_port=None, seed_peers=[], seed_mode=0, dev_mode=False, log_level=None, database='db/ob.db', disable_upnp=False, disable_open_browser=False): logging.basicConfig(level=int(log_level), format='%(asctime)s - %(name)s - \ %(levelname)s - %(message)s', filename=log_file) locallogger = logging.getLogger('[%s] %s' % (market_id, 'root')) handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=50, backupCount=0) locallogger.addHandler(handler) application = MarketApplication(my_market_ip, my_market_port, market_id, bm_user, bm_pass, bm_port, seed_peers, seed_mode, dev_mode, database) error = True p2p_port = 12345 if http_port == -1: http_port = get_random_free_tcp_port(8889, 8988) while error: try: application.listen(http_port, http_ip) error = False except: http_port += 1 if not disable_upnp: application.setup_upnp_port_mappings(http_port, p2p_port) else: print "Disabling upnp setup" locallogger.info("Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port)) print "Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port) if disable_open_browser == "0": open_default_webbrowser('http://%s:%s' % (http_ip, http_port)) # handle shutdown def shutdown(x, y): locallogger = logging.getLogger('[%s] %s' % (market_id, 'root')) locallogger.info("Received TERMINATE, exiting...") # application.get_transport().broadcast_goodbye() application.cleanup_upnp_port_mapping() tornado.ioloop.IOLoop.instance().stop() # TODO: # we should implement the shutdown of the dht connections, db connection, bitmessage connection # maybe this was meant to do all that but nobody ever got around it. # application.market.p.kill() os._exit(0) try: signal.signal(signal.SIGTERM, shutdown) except ValueError: # not the main thread pass if not tornado.ioloop.IOLoop.instance(): ioloop.install() else: tornado.ioloop.IOLoop.instance().start()
def attempt_browser_open(ob_ctx): if not ob_ctx.disable_open_browser: open_default_webbrowser('http://%s:%s' % (ob_ctx.http_ip, ob_ctx.http_port))
def start_node(my_market_ip, my_market_port, http_ip, http_port, log_file, market_id, bm_user=None, bm_pass=None, bm_port=None, seed_peers=None, seed_mode=0, dev_mode=False, log_level=None, database='db/ob.db', disable_upnp=False, disable_open_browser=False, disable_sqlite_crypt=False, disable_ip_update=False): if seed_peers is None: seed_peers = [] try: logging.basicConfig( level=int(log_level), format=u'%(asctime)s - %(name)s - %(levelname)s - %(message)s', filename=log_file ) logging._defaultFormatter = logging.Formatter(u'%(message)s') locallogger = logging.getLogger('[%s] %s' % (market_id, 'root')) handler = logging.handlers.RotatingFileHandler( log_file, encoding='utf-8', maxBytes=50000000, backupCount=1 ) locallogger.addHandler(handler) except Exception as e: print "Could not setup logger, continuing: ", e.message application = MarketApplication(my_market_ip, my_market_port, market_id, bm_user, bm_pass, bm_port, seed_peers, seed_mode, dev_mode, database, disable_sqlite_crypt, disable_ip_update) error = True p2p_port = my_market_port if http_port == -1: http_port = get_random_free_tcp_port(8889, 8988) while error: try: application.listen(http_port, http_ip) error = False except: http_port += 1 if not disable_upnp: application.setup_upnp_port_mappings(http_port, p2p_port) else: print "Disabling upnp setup" locallogger.info("Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port)) print "Started OpenBazaar Web App at http://%s:%s" % (http_ip, http_port) print "Use ./stop.sh to stop" if not disable_open_browser: open_default_webbrowser('http://%s:%s' % (http_ip, http_port)) try: signal.signal(signal.SIGTERM, application.shutdown) except ValueError: # not the main thread pass if not tornado.ioloop.IOLoop.instance(): ioloop.install() else: try: tornado.ioloop.IOLoop.instance().start() except Exception as e: pass