forked from golemfactory/clay
-
Notifications
You must be signed in to change notification settings - Fork 6
/
golemapp.py
40 lines (31 loc) · 1.42 KB
/
golemapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from multiprocessing import freeze_support
import click
from gnr.gnrstartapp import start_app
from gnr.node import GNRNode # TODO: This also configures the logging.
from golem.core.common import config_logging
@click.command()
@click.option('--gui/--nogui', default=True)
@click.option('--payments/--nopayments', default=True)
@click.option('--datadir', '-d', type=click.Path())
@click.option('--node-address', '-a', multiple=False, type=click.STRING,
callback=GNRNode.parse_node_addr,
help="Network address to use for this node")
@click.option('--peer', '-p', multiple=True, callback=GNRNode.parse_peer,
help="Connect with given peer: <ipv4_addr>:<port> or [<ipv6_addr>]:<port>")
@click.option('--task', '-t', multiple=True, type=click.Path(exists=True),
callback=GNRNode.parse_task_file,
help="Request task from file")
@click.option('--multiprocessing-fork', nargs=1, default=None)
def start(gui, payments, datadir, node_address, peer, task, multiprocessing_fork):
freeze_support()
if gui:
start_app(datadir=datadir, rendering=True,
transaction_system=payments)
else:
config_logging()
node = GNRNode(datadir=datadir, node_address=node_address,
transaction_system=payments)
node.initialize()
node.connect_with_peers(peer)
node.add_tasks(task)
node.run(use_rpc=True)