@@ -327,7 +327,6 @@ if __name__ == '__main__':
327327 config = SimpleConfig (config_options )
328328
329329 cmdname = config .get ('cmd' )
330- subcommand = config .get ('subcommand' )
331330
332331 if config .get ('testnet' ):
333332 constants .set_testnet ()
@@ -338,7 +337,7 @@ if __name__ == '__main__':
338337 elif config .get ('lightning' ) and not config .get ('reckless' ):
339338 raise Exception ('lightning branch not available on mainnet' )
340339
341- if cmdname == 'daemon' and subcommand == 'start' :
340+ if cmdname == 'daemon' and config . get ( "detach" ) :
342341 # fork before creating the asyncio event loop
343342 pid = os .fork ()
344343 if pid :
@@ -370,32 +369,26 @@ if __name__ == '__main__':
370369
371370 elif cmdname == 'daemon' :
372371
373- if subcommand in [None , 'start' ]:
374- configure_logging (config )
375- fd = daemon .get_file_descriptor (config )
376- if fd is not None :
377- # run daemon
378- init_plugins (config , 'cmdline' )
379- d = daemon .Daemon (config , fd )
380- if config .get ('websocket_server' ):
381- from electrum import websockets
382- websockets .WebSocketServer (config , d .network )
383- if config .get ('requests_dir' ):
384- path = os .path .join (config .get ('requests_dir' ), 'index.html' )
385- if not os .path .exists (path ):
386- print ("Requests directory not configured." )
387- print ("You can configure it using https://github.com/spesmilo/electrum-merchant" )
388- sys_exit (1 )
389- d .run_daemon ()
390- sys_exit (0 )
391- else :
392- result = daemon .request (config , 'daemon' , (config_options ,))
372+ configure_logging (config )
373+ fd = daemon .get_file_descriptor (config )
374+ if fd is not None :
375+ # run daemon
376+ init_plugins (config , 'cmdline' )
377+ d = daemon .Daemon (config , fd )
378+ if config .get ('websocket_server' ):
379+ from electrum import websockets
380+ websockets .WebSocketServer (config , d .network )
381+ if config .get ('requests_dir' ):
382+ path = os .path .join (config .get ('requests_dir' ), 'index.html' )
383+ if not os .path .exists (path ):
384+ print ("Requests directory not configured." )
385+ print ("You can configure it using https://github.com/spesmilo/electrum-merchant" )
386+ sys_exit (1 )
387+ d .run_daemon ()
388+ sys_exit (0 )
393389 else :
394- try :
395- result = daemon .request (config , 'daemon' , (config_options ,))
396- except daemon .DaemonNotRunning :
397- print_msg ("Daemon not running" )
398- sys_exit (1 )
390+ print_msg ("Daemon already running" )
391+ sys_exit (1 )
399392 else :
400393 # command line
401394 cmd = known_commands [cmdname ]
@@ -406,7 +399,7 @@ if __name__ == '__main__':
406399 try :
407400 result = daemon .request (config , 'run_cmdline' , (config_options ,), timeout )
408401 except daemon .DaemonNotRunning :
409- print_msg ("Daemon not running; try 'electrum daemon start '" )
402+ print_msg ("Daemon not running; try 'electrum daemon -d '" )
410403 if not cmd .requires_network :
411404 print_msg ("To run this command without a daemon, use --offline" )
412405 sys_exit (1 )
0 commit comments