Add traceback for daemon errors
This commit is contained in:
parent
5aaee6b608
commit
b01933913f
@ -15,7 +15,7 @@ import time
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from server.daemon import Daemon, DaemonError
|
from server.daemon import DaemonError
|
||||||
from server.version import VERSION
|
from server.version import VERSION
|
||||||
from lib.hash import hash_to_str
|
from lib.hash import hash_to_str
|
||||||
from lib.util import chunks, formatted_time, LoggedClass
|
from lib.util import chunks, formatted_time, LoggedClass
|
||||||
@ -138,8 +138,9 @@ class BlockProcessor(server.db.DB):
|
|||||||
Coordinate backing up in case of chain reorganisations.
|
Coordinate backing up in case of chain reorganisations.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, env):
|
def __init__(self, env, daemon):
|
||||||
super().__init__(env)
|
super().__init__(env)
|
||||||
|
self.daemon = daemon
|
||||||
|
|
||||||
# These are our state as we move ahead of DB state
|
# These are our state as we move ahead of DB state
|
||||||
self.fs_height = self.db_height
|
self.fs_height = self.db_height
|
||||||
@ -148,7 +149,6 @@ class BlockProcessor(server.db.DB):
|
|||||||
self.tip = self.db_tip
|
self.tip = self.db_tip
|
||||||
self.tx_count = self.db_tx_count
|
self.tx_count = self.db_tx_count
|
||||||
|
|
||||||
self.daemon = Daemon(self.coin.daemon_urls(env.daemon_url))
|
|
||||||
self.caught_up_event = asyncio.Event()
|
self.caught_up_event = asyncio.Event()
|
||||||
self.task_queue = asyncio.Queue()
|
self.task_queue = asyncio.Queue()
|
||||||
self.stop = False
|
self.stop = False
|
||||||
@ -195,7 +195,8 @@ class BlockProcessor(server.db.DB):
|
|||||||
pass
|
pass
|
||||||
self.logger.info('preparing clean shutdown')
|
self.logger.info('preparing clean shutdown')
|
||||||
self.stop = True
|
self.stop = True
|
||||||
self.add_task(do_nothing) # Ensure something is on the queue
|
# Ensure something is on the queue so main_loop notices self.stop
|
||||||
|
self.add_task(do_nothing)
|
||||||
|
|
||||||
async def main_loop(self):
|
async def main_loop(self):
|
||||||
'''Main loop for block processing.'''
|
'''Main loop for block processing.'''
|
||||||
|
|||||||
@ -21,6 +21,7 @@ from lib.jsonrpc import JSONRPC, RPCError, RequestBase
|
|||||||
from lib.hash import sha256, double_sha256, hash_to_str, hex_str_to_hash
|
from lib.hash import sha256, double_sha256, hash_to_str, hex_str_to_hash
|
||||||
import lib.util as util
|
import lib.util as util
|
||||||
from server.block_processor import BlockProcessor
|
from server.block_processor import BlockProcessor
|
||||||
|
from server.daemon import Daemon
|
||||||
from server.irc import IRC
|
from server.irc import IRC
|
||||||
from server.session import LocalRPC, ElectrumX
|
from server.session import LocalRPC, ElectrumX
|
||||||
from server.mempool import MemPool
|
from server.mempool import MemPool
|
||||||
@ -54,8 +55,8 @@ class Controller(util.LoggedClass):
|
|||||||
self.loop = asyncio.get_event_loop()
|
self.loop = asyncio.get_event_loop()
|
||||||
self.start = time.time()
|
self.start = time.time()
|
||||||
self.coin = env.coin
|
self.coin = env.coin
|
||||||
self.bp = BlockProcessor(env)
|
self.daemon = Daemon(env.coin.daemon_urls(env.daemon_url))
|
||||||
self.daemon = self.bp.daemon
|
self.bp = BlockProcessor(env, self.daemon)
|
||||||
self.mempool = MemPool(self.bp)
|
self.mempool = MemPool(self.bp)
|
||||||
self.irc = IRC(env)
|
self.irc = IRC(env)
|
||||||
self.env = env
|
self.env = env
|
||||||
|
|||||||
@ -10,6 +10,7 @@ daemon.'''
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import traceback
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
@ -82,11 +83,14 @@ class Daemon(util.LoggedClass):
|
|||||||
except aiohttp.ClientConnectionError:
|
except aiohttp.ClientConnectionError:
|
||||||
log_error('connection problem - is your daemon running?')
|
log_error('connection problem - is your daemon running?')
|
||||||
except self.DaemonWarmingUpError:
|
except self.DaemonWarmingUpError:
|
||||||
log_error('still starting up checking blocks.')
|
log_error('starting up checking blocks.')
|
||||||
except (asyncio.CancelledError, DaemonError):
|
except (asyncio.CancelledError, DaemonError):
|
||||||
raise
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
self.log_error(traceback.format_exc())
|
||||||
|
self.log_error('response was: {}'.format(resp))
|
||||||
log_error('request gave unexpected error: {}.'.format(e))
|
log_error('request gave unexpected error: {}.'.format(e))
|
||||||
|
|
||||||
if secs >= max_secs and len(self.urls) > 1:
|
if secs >= max_secs and len(self.urls) > 1:
|
||||||
self.url_index = (self.url_index + 1) % len(self.urls)
|
self.url_index = (self.url_index + 1) % len(self.urls)
|
||||||
logged_url = self.logged_url(self.urls[self.url_index])
|
logged_url = self.logged_url(self.urls[self.url_index])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user