mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
replace daemon 'start' subdommand with -d
This commit is contained in:
parent
241a37d12d
commit
7f870f5e09
4 changed files with 32 additions and 52 deletions
|
@ -1139,8 +1139,7 @@ def get_parser():
|
||||||
add_global_options(parser_gui)
|
add_global_options(parser_gui)
|
||||||
# daemon
|
# daemon
|
||||||
parser_daemon = subparsers.add_parser('daemon', help="Run Daemon")
|
parser_daemon = subparsers.add_parser('daemon', help="Run Daemon")
|
||||||
parser_daemon.add_argument("subcommand", choices=['start', 'status', 'stop', 'load_wallet', 'close_wallet'], nargs='?')
|
parser_daemon.add_argument("-d", "--detached", action="store_true", dest="detach", default=False, help="run daemon in detached mode")
|
||||||
#parser_daemon.set_defaults(func=run_daemon)
|
|
||||||
add_network_options(parser_daemon)
|
add_network_options(parser_daemon)
|
||||||
add_global_options(parser_daemon)
|
add_global_options(parser_daemon)
|
||||||
# commands
|
# commands
|
||||||
|
|
|
@ -243,7 +243,6 @@ class Daemon(Logger):
|
||||||
self.methods = jsonrpcserver.methods.Methods()
|
self.methods = jsonrpcserver.methods.Methods()
|
||||||
self.methods.add(self.ping)
|
self.methods.add(self.ping)
|
||||||
self.methods.add(self.gui)
|
self.methods.add(self.gui)
|
||||||
self.methods.add(self.daemon)
|
|
||||||
self.cmd_runner = Commands(self.config, None, self.network, self)
|
self.cmd_runner = Commands(self.config, None, self.network, self)
|
||||||
for cmdname in known_commands:
|
for cmdname in known_commands:
|
||||||
self.methods.add(getattr(self.cmd_runner, cmdname))
|
self.methods.add(getattr(self.cmd_runner, cmdname))
|
||||||
|
@ -261,17 +260,6 @@ class Daemon(Logger):
|
||||||
async def ping(self):
|
async def ping(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def daemon(self, config_options):
|
|
||||||
config = SimpleConfig(config_options)
|
|
||||||
sub = config.get('subcommand')
|
|
||||||
assert sub in [None, 'start', 'stop']
|
|
||||||
if sub in [None, 'start']:
|
|
||||||
response = "Daemon already running"
|
|
||||||
elif sub == 'stop':
|
|
||||||
self.stop()
|
|
||||||
response = "Daemon stopped"
|
|
||||||
return response
|
|
||||||
|
|
||||||
async def gui(self, config_options):
|
async def gui(self, config_options):
|
||||||
config = SimpleConfig(config_options)
|
config = SimpleConfig(config_options)
|
||||||
if self.gui_object:
|
if self.gui_object:
|
||||||
|
|
|
@ -89,9 +89,9 @@ fi
|
||||||
|
|
||||||
# start daemons. Bob is started first because he is listening
|
# start daemons. Bob is started first because he is listening
|
||||||
if [[ $1 == "start" ]]; then
|
if [[ $1 == "start" ]]; then
|
||||||
$bob daemon start
|
$bob daemon -d
|
||||||
$alice daemon start
|
$alice daemon -d
|
||||||
$carol daemon start
|
$carol daemon -d
|
||||||
$bob load_wallet
|
$bob load_wallet
|
||||||
$alice load_wallet
|
$alice load_wallet
|
||||||
$carol load_wallet
|
$carol load_wallet
|
||||||
|
@ -158,7 +158,7 @@ fi
|
||||||
|
|
||||||
if [[ $1 == "redeem_htlcs" ]]; then
|
if [[ $1 == "redeem_htlcs" ]]; then
|
||||||
$bob stop
|
$bob stop
|
||||||
ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=10 $bob daemon start
|
ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=10 $bob daemon -d
|
||||||
sleep 1
|
sleep 1
|
||||||
$bob load_wallet
|
$bob load_wallet
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -204,7 +204,7 @@ fi
|
||||||
|
|
||||||
if [[ $1 == "breach_with_unspent_htlc" ]]; then
|
if [[ $1 == "breach_with_unspent_htlc" ]]; then
|
||||||
$bob stop
|
$bob stop
|
||||||
ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=3 $bob daemon start
|
ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=3 $bob daemon -d
|
||||||
sleep 1
|
sleep 1
|
||||||
$bob load_wallet
|
$bob load_wallet
|
||||||
wait_for_balance alice 1
|
wait_for_balance alice 1
|
||||||
|
@ -236,7 +236,7 @@ fi
|
||||||
|
|
||||||
if [[ $1 == "breach_with_spent_htlc" ]]; then
|
if [[ $1 == "breach_with_spent_htlc" ]]; then
|
||||||
$bob stop
|
$bob stop
|
||||||
ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=3 $bob daemon start
|
ELECTRUM_DEBUG_LIGHTNING_SETTLE_DELAY=3 $bob daemon -d
|
||||||
sleep 1
|
sleep 1
|
||||||
$bob load_wallet
|
$bob load_wallet
|
||||||
wait_for_balance alice 1
|
wait_for_balance alice 1
|
||||||
|
@ -276,7 +276,7 @@ if [[ $1 == "breach_with_spent_htlc" ]]; then
|
||||||
# (to_local needs to_self_delay blocks; htlc needs whatever we put in invoice)
|
# (to_local needs to_self_delay blocks; htlc needs whatever we put in invoice)
|
||||||
new_blocks 150
|
new_blocks 150
|
||||||
$alice stop
|
$alice stop
|
||||||
$alice daemon start
|
$alice daemon -d
|
||||||
sleep 1
|
sleep 1
|
||||||
$alice load_wallet -w /tmp/alice/regtest/wallets/toxic_wallet
|
$alice load_wallet -w /tmp/alice/regtest/wallets/toxic_wallet
|
||||||
# wait until alice has spent both ctx outputs
|
# wait until alice has spent both ctx outputs
|
||||||
|
@ -285,7 +285,7 @@ if [[ $1 == "breach_with_spent_htlc" ]]; then
|
||||||
wait_until_spent $ctx_id 1
|
wait_until_spent $ctx_id 1
|
||||||
new_blocks 1
|
new_blocks 1
|
||||||
echo "bob comes back"
|
echo "bob comes back"
|
||||||
$bob daemon start
|
$bob daemon -d
|
||||||
sleep 1
|
sleep 1
|
||||||
$bob load_wallet
|
$bob load_wallet
|
||||||
wait_for_balance bob 0.049
|
wait_for_balance bob 0.049
|
||||||
|
@ -299,8 +299,8 @@ if [[ $1 == "watchtower" ]]; then
|
||||||
$alice setconfig --offline watchtower_url http://127.0.0.1:12345
|
$alice setconfig --offline watchtower_url http://127.0.0.1:12345
|
||||||
$carol setconfig --offline watchtower_host 127.0.0.1
|
$carol setconfig --offline watchtower_host 127.0.0.1
|
||||||
$carol setconfig --offline watchtower_port 12345
|
$carol setconfig --offline watchtower_port 12345
|
||||||
$carol daemon start
|
$carol daemon -d
|
||||||
$alice daemon start
|
$alice daemon -d
|
||||||
sleep 1
|
sleep 1
|
||||||
$alice load_wallet
|
$alice load_wallet
|
||||||
wait_for_balance alice 1
|
wait_for_balance alice 1
|
||||||
|
|
13
run_electrum
13
run_electrum
|
@ -327,7 +327,6 @@ if __name__ == '__main__':
|
||||||
config = SimpleConfig(config_options)
|
config = SimpleConfig(config_options)
|
||||||
|
|
||||||
cmdname = config.get('cmd')
|
cmdname = config.get('cmd')
|
||||||
subcommand = config.get('subcommand')
|
|
||||||
|
|
||||||
if config.get('testnet'):
|
if config.get('testnet'):
|
||||||
constants.set_testnet()
|
constants.set_testnet()
|
||||||
|
@ -338,7 +337,7 @@ if __name__ == '__main__':
|
||||||
elif config.get('lightning') and not config.get('reckless'):
|
elif config.get('lightning') and not config.get('reckless'):
|
||||||
raise Exception('lightning branch not available on mainnet')
|
raise Exception('lightning branch not available on mainnet')
|
||||||
|
|
||||||
if cmdname == 'daemon' and subcommand == 'start':
|
if cmdname == 'daemon' and config.get("detach"):
|
||||||
# fork before creating the asyncio event loop
|
# fork before creating the asyncio event loop
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if pid:
|
if pid:
|
||||||
|
@ -370,7 +369,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
elif cmdname == 'daemon':
|
elif cmdname == 'daemon':
|
||||||
|
|
||||||
if subcommand in [None, 'start']:
|
|
||||||
configure_logging(config)
|
configure_logging(config)
|
||||||
fd = daemon.get_file_descriptor(config)
|
fd = daemon.get_file_descriptor(config)
|
||||||
if fd is not None:
|
if fd is not None:
|
||||||
|
@ -389,12 +387,7 @@ if __name__ == '__main__':
|
||||||
d.run_daemon()
|
d.run_daemon()
|
||||||
sys_exit(0)
|
sys_exit(0)
|
||||||
else:
|
else:
|
||||||
result = daemon.request(config, 'daemon', (config_options,))
|
print_msg("Daemon already running")
|
||||||
else:
|
|
||||||
try:
|
|
||||||
result = daemon.request(config, 'daemon', (config_options,))
|
|
||||||
except daemon.DaemonNotRunning:
|
|
||||||
print_msg("Daemon not running")
|
|
||||||
sys_exit(1)
|
sys_exit(1)
|
||||||
else:
|
else:
|
||||||
# command line
|
# command line
|
||||||
|
@ -406,7 +399,7 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
result = daemon.request(config, 'run_cmdline', (config_options,), timeout)
|
result = daemon.request(config, 'run_cmdline', (config_options,), timeout)
|
||||||
except daemon.DaemonNotRunning:
|
except daemon.DaemonNotRunning:
|
||||||
print_msg("Daemon not running; try 'electrum daemon start'")
|
print_msg("Daemon not running; try 'electrum daemon -d'")
|
||||||
if not cmd.requires_network:
|
if not cmd.requires_network:
|
||||||
print_msg("To run this command without a daemon, use --offline")
|
print_msg("To run this command without a daemon, use --offline")
|
||||||
sys_exit(1)
|
sys_exit(1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue