mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
setup changes
This commit is contained in:
parent
d911af0315
commit
131d7fad14
@ -1,7 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from bigchaindb.core import Bigchain # noqa
|
|
||||||
|
|
||||||
|
|
||||||
def e(key, default=None, conv=None):
|
def e(key, default=None, conv=None):
|
||||||
@ -35,10 +34,17 @@ config = {
|
|||||||
'private': e('BIGCHAIN_KEYPAIR_PRIVATE')
|
'private': e('BIGCHAIN_KEYPAIR_PRIVATE')
|
||||||
},
|
},
|
||||||
'keyring': [
|
'keyring': [
|
||||||
]
|
],
|
||||||
|
'statsd': {
|
||||||
|
'host': e('BIGCHAIN_STATSD_HOST', default='localhost'),
|
||||||
|
'port': e('BIGCHAIN_STATSD_PORT', default=8125),
|
||||||
|
'rate': e('BIGCHAIN_STATSD_SAMPLERATE', default=0.01)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# We need to maintain a backup copy of the original config dict in case
|
# We need to maintain a backup copy of the original config dict in case
|
||||||
# the user wants to reconfigure the node. Check ``bigchaindb.config_utils``
|
# the user wants to reconfigure the node. Check ``bigchaindb.config_utils``
|
||||||
# for more info.
|
# for more info.
|
||||||
_config = copy.deepcopy(config)
|
_config = copy.deepcopy(config)
|
||||||
|
from bigchaindb.core import Bigchain # noqa
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import queue
|
|||||||
|
|
||||||
import rethinkdb as r
|
import rethinkdb as r
|
||||||
|
|
||||||
|
import bigchaindb
|
||||||
from bigchaindb import Bigchain
|
from bigchaindb import Bigchain
|
||||||
from bigchaindb.monitor import Monitor
|
from bigchaindb.monitor import Monitor
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# obviously the hostname should come from an environment variable or setting
|
# obviously the hostname should come from an environment variable or setting
|
||||||
# http://i.imgur.com/qciaOed.jpg
|
# http://i.imgur.com/qciaOed.jpg
|
||||||
c = Monitor(host='statsd_1')
|
c = Monitor()
|
||||||
|
|
||||||
|
|
||||||
class Block(object):
|
class Block(object):
|
||||||
@ -38,7 +39,7 @@ class Block(object):
|
|||||||
b = Bigchain()
|
b = Bigchain()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
c.gauge('tx_queue_gauge', self.q_tx_to_validate.qsize(), rate=0.01)
|
c.gauge('tx_queue_gauge', self.q_tx_to_validate.qsize(), rate=bigchaindb.config['statsd']['rate'])
|
||||||
tx = self.q_new_transaction.get()
|
tx = self.q_new_transaction.get()
|
||||||
|
|
||||||
# poison pill
|
# poison pill
|
||||||
|
@ -56,6 +56,10 @@ def run_configure(args, skip_if_exists=False):
|
|||||||
val = conf['database'][key]
|
val = conf['database'][key]
|
||||||
conf['database'][key] = input('Database {}? (default `{}`): '.format(key, val)) or val
|
conf['database'][key] = input('Database {}? (default `{}`): '.format(key, val)) or val
|
||||||
|
|
||||||
|
for key in ('host', 'port', 'rate'):
|
||||||
|
val = conf['statsd'][key]
|
||||||
|
conf['statsd'][key] = input('Statsd {}? (default `{}`): '.format(key, val)) or val
|
||||||
|
|
||||||
bigchaindb.config_utils.write_config(conf, config_path)
|
bigchaindb.config_utils.write_config(conf, config_path)
|
||||||
print('Ready to go!')
|
print('Ready to go!')
|
||||||
|
|
||||||
|
@ -12,9 +12,8 @@ from bigchaindb import exceptions
|
|||||||
from bigchaindb.crypto import hash_data, PublicKey, PrivateKey, generate_key_pair
|
from bigchaindb.crypto import hash_data, PublicKey, PrivateKey, generate_key_pair
|
||||||
from bigchaindb.monitor import Monitor
|
from bigchaindb.monitor import Monitor
|
||||||
|
|
||||||
# obviously the hostname should come from an environment variable or setting
|
c = Monitor()
|
||||||
|
|
||||||
c = Monitor(host='statsd_1')
|
|
||||||
|
|
||||||
class GenesisBlockAlreadyExistsError(Exception):
|
class GenesisBlockAlreadyExistsError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -72,7 +71,7 @@ class Bigchain(object):
|
|||||||
def reconnect(self):
|
def reconnect(self):
|
||||||
return r.connect(host=self.host, port=self.port, db=self.dbname)
|
return r.connect(host=self.host, port=self.port, db=self.dbname)
|
||||||
|
|
||||||
@c.timer('create_transaction', rate=0.01)
|
@c.timer('create_transaction', rate=bigchaindb.config['statsd']['rate'])
|
||||||
def create_transaction(self, current_owner, new_owner, tx_input, operation, payload=None):
|
def create_transaction(self, current_owner, new_owner, tx_input, operation, payload=None):
|
||||||
"""Create a new transaction
|
"""Create a new transaction
|
||||||
|
|
||||||
@ -182,7 +181,7 @@ class Bigchain(object):
|
|||||||
public_key = PublicKey(public_key_base58)
|
public_key = PublicKey(public_key_base58)
|
||||||
return public_key.verify(self.serialize(data), signature)
|
return public_key.verify(self.serialize(data), signature)
|
||||||
|
|
||||||
@c.timer('write_transaction', rate=0.01)
|
@c.timer('write_transaction', rate=bigchaindb.config['statsd']['rate'])
|
||||||
def write_transaction(self, signed_transaction):
|
def write_transaction(self, signed_transaction):
|
||||||
"""Write the transaction to bigchain.
|
"""Write the transaction to bigchain.
|
||||||
|
|
||||||
@ -319,7 +318,7 @@ class Bigchain(object):
|
|||||||
|
|
||||||
return owned
|
return owned
|
||||||
|
|
||||||
@c.timer('validate_transaction')#, rate=0.01)
|
@c.timer('validate_transaction', rate=bigchaindb.config['statsd']['rate'])
|
||||||
def validate_transaction(self, transaction):
|
def validate_transaction(self, transaction):
|
||||||
"""Validate a transaction.
|
"""Validate a transaction.
|
||||||
|
|
||||||
|
@ -1,10 +1,30 @@
|
|||||||
import statsd
|
import statsd
|
||||||
from platform import node
|
from platform import node
|
||||||
|
|
||||||
|
import bigchaindb
|
||||||
|
from bigchaindb import config_utils
|
||||||
|
|
||||||
class Monitor(statsd.StatsClient):
|
class Monitor(statsd.StatsClient):
|
||||||
|
"""Set up statsd monitoring
|
||||||
|
|
||||||
|
"""
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Overrides statsd client, fixing prefix to messages and loading configuration
|
||||||
|
|
||||||
|
Args:
|
||||||
|
*args: arguments (identical to Statsclient)
|
||||||
|
**kwargs: keyword arguments (identical to Statsclient)
|
||||||
|
"""
|
||||||
|
config_utils.autoconfigure()
|
||||||
|
|
||||||
if not kwargs:
|
if not kwargs:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
|
||||||
|
# set prefix, parameters from configuration file
|
||||||
if not kwargs.get('prefix'):
|
if not kwargs.get('prefix'):
|
||||||
kwargs['prefix'] = '{hostname}.'.format(hostname=node())
|
kwargs['prefix'] = '{hostname}.'.format(hostname=node())
|
||||||
|
if not kwargs.get('host'):
|
||||||
|
kwargs['host'] = bigchaindb.config['statsd']['host']
|
||||||
|
if not kwargs.get('port'):
|
||||||
|
kwargs['port'] = bigchaindb.config['statsd']['port']
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user