Init wot plugin

This commit is contained in:
Kevin F 2022-08-16 09:54:54 -05:00
parent b2ebc56419
commit 3b8644fa8f
3 changed files with 16 additions and 6 deletions

View File

@ -62,7 +62,7 @@ def daemon():
def _handle_sig_term(signum, frame):
sys.exit(0)
with open(filepaths.pid_file, 'w') as f:
f.write(str(os.getpid()))
@ -77,14 +77,15 @@ def daemon():
logger.info(
f"Onionr daemon is running under pid {os.getpid()}", terminal=True)
events.event('init', threaded=False)
events.event('afterinit', threaded=False)
events.event('daemon_start')
add_onionr_thread(
clean_block_database, 60, 'clean_block_database', initial_sleep=0)
Thread(
target=gossip.start_gossip_threads,
daemon=True,
target=gossip.start_gossip_threads,
daemon=True,
name='start_gossip_threads').start()
try:

View File

@ -1 +1,7 @@
plugin_apis = {}
#
from typing import Callable, Dict
# plugin apis are methods intended to be available to the rpc
# plugin, this is so plugins can provide apis to other plugins
# plugins add their methods during or before afterinit event
plugin_apis: Dict[str, Callable] = {}

View File

@ -43,7 +43,7 @@ import ujson
jsonrpc.manager.json = ujson
# RPC modules map Onionr APIs to the RPC dispacher
from rpc import blocks
from rpc import blocks, pluginrpcmethods
class OnionrRPC(object):
@ -57,6 +57,10 @@ class OnionrRPC(object):
return response.json
def on_afterinit(api, data=None):
pluginrpcmethods.add_plugin_rpc_methods()
def on_init(api, data=None):
config = {
#'server.socket_file': socket_file_path,
@ -68,4 +72,3 @@ def on_init(api, data=None):
add_onionr_thread(
cherrypy.quickstart, 5, 'OnionrRPCServer',
OnionrRPC(), initial_sleep=0)