fixed subprocesspow not exiting on wsl
This commit is contained in:
parent
e831a27ae3
commit
eaf61c280a
@ -66,6 +66,10 @@ class PrivateEndpoints:
|
|||||||
return send_from_directory(config.get('www.private.path',
|
return send_from_directory(config.get('www.private.path',
|
||||||
'static-data/www/private/'), path)
|
'static-data/www/private/'), path)
|
||||||
|
|
||||||
|
@private_endpoints_bp.route('/getpid')
|
||||||
|
def get_pid():
|
||||||
|
return Response(str(os.getpid()))
|
||||||
|
|
||||||
@private_endpoints_bp.route('/hitcount')
|
@private_endpoints_bp.route('/hitcount')
|
||||||
def get_hit_count():
|
def get_hit_count():
|
||||||
return Response(str(client_api.publicAPI.hitCount))
|
return Response(str(client_api.publicAPI.hitCount))
|
||||||
|
@ -44,6 +44,10 @@ def _lan_work(peer: LANIP):
|
|||||||
url + f'get/{block}', stream=True).raw.read(6000000))
|
url + f'get/{block}', stream=True).raw.read(6000000))
|
||||||
except onionrexceptions.InvalidMetadata:
|
except onionrexceptions.InvalidMetadata:
|
||||||
logger.warn(f"Could not get {block} from lan peer")
|
logger.warn(f"Could not get {block} from lan peer")
|
||||||
|
except onionrexceptions.InvalidProof:
|
||||||
|
logger.warn(
|
||||||
|
f"Invalid proof for {block} from lan peer {peer}", terminal=True)
|
||||||
|
break
|
||||||
|
|
||||||
for port in ports:
|
for port in ports:
|
||||||
try:
|
try:
|
||||||
|
@ -120,7 +120,7 @@ class NetController:
|
|||||||
tor_pid_file.write(str(tor.pid))
|
tor_pid_file.write(str(tor.pid))
|
||||||
|
|
||||||
multiprocessing.Process(target=watchdog.watchdog,
|
multiprocessing.Process(target=watchdog.watchdog,
|
||||||
args=[os.getpid(), tor.pid]).start()
|
args=[os.getpid(), tor.pid], daemon=True).start()
|
||||||
|
|
||||||
logger.info('Finished starting Tor.', terminal=True)
|
logger.info('Finished starting Tor.', terminal=True)
|
||||||
|
|
||||||
|
@ -129,9 +129,17 @@ def daemon():
|
|||||||
"""Start Onionr's primary threads for communicator, API server, node, and LAN."""
|
"""Start Onionr's primary threads for communicator, API server, node, and LAN."""
|
||||||
|
|
||||||
def _handle_sig_term(signum, frame):
|
def _handle_sig_term(signum, frame):
|
||||||
|
pid = str(os.getpid())
|
||||||
|
main_pid = localcommand.local_command('/getpid')
|
||||||
|
#logger.info(main_pid, terminal=True)
|
||||||
|
if main_pid and main_pid == pid:
|
||||||
logger.info(
|
logger.info(
|
||||||
"Received sigterm, shutting down gracefully", terminal=True)
|
f"Received sigterm, shutting down gracefully. PID: {pid}", terminal=True)
|
||||||
localcommand.local_command('/shutdownclean')
|
localcommand.local_command('/shutdownclean')
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
f"Recieved sigterm in child process or fork, exiting. PID: {pid}")
|
||||||
|
sys.exit(0)
|
||||||
signal.signal(signal.SIGTERM, _handle_sig_term)
|
signal.signal(signal.SIGTERM, _handle_sig_term)
|
||||||
|
|
||||||
# Determine if Onionr is in offline mode.
|
# Determine if Onionr is in offline mode.
|
||||||
@ -233,11 +241,6 @@ def daemon():
|
|||||||
filenuke.nuke.clean_tree(identifyhome.identify_home())
|
filenuke.nuke.clean_tree(identifyhome.identify_home())
|
||||||
|
|
||||||
|
|
||||||
def _ignore_sigint(sig, frame): # pylint: disable=W0612,W0613
|
|
||||||
"""Space intentionally left blank."""
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def start(override: bool = False):
|
def start(override: bool = False):
|
||||||
"""If no lock file, make one and start onionr.
|
"""If no lock file, make one and start onionr.
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class SubprocessPOW:
|
|||||||
parent_conn, child_conn = Pipe()
|
parent_conn, child_conn = Pipe()
|
||||||
p = Process(target=self.do_pow, args=(child_conn,), daemon=True)
|
p = Process(target=self.do_pow, args=(child_conn,), daemon=True)
|
||||||
p.start()
|
p.start()
|
||||||
p.join()
|
#p.join()
|
||||||
payload = None
|
payload = None
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
@ -105,7 +105,7 @@ class SubprocessPOW:
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
parent_conn.send('shutdown')
|
p.terminate()
|
||||||
self.payload = payload
|
self.payload = payload
|
||||||
|
|
||||||
def do_pow(self, pipe):
|
def do_pow(self, pipe):
|
||||||
|
@ -48,7 +48,7 @@ def find_vanity_mnemonic(start_words: str, queue):
|
|||||||
def _start(start_words, obj):
|
def _start(start_words, obj):
|
||||||
done = False
|
done = False
|
||||||
q = Queue()
|
q = Queue()
|
||||||
p = Process(target=find_vanity_mnemonic, args=[start_words, q])
|
p = Process(target=find_vanity_mnemonic, args=[start_words, q], daemon=True)
|
||||||
p.daemon = True
|
p.daemon = True
|
||||||
p.start()
|
p.start()
|
||||||
rec = None
|
rec = None
|
||||||
@ -68,7 +68,7 @@ def handler(start_words: str):
|
|||||||
obj = lambda test: None
|
obj = lambda test: None
|
||||||
obj.done = False
|
obj.done = False
|
||||||
for x in range(multiprocessing.cpu_count()):
|
for x in range(multiprocessing.cpu_count()):
|
||||||
threading.Thread(target=_start, args=[start_words, obj]).start()
|
threading.Thread(target=_start, args=[start_words, obj], daemon=True).start()
|
||||||
while not obj.done:
|
while not obj.done:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return obj.result
|
return obj.result
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
"tor": true
|
"tor": true
|
||||||
},
|
},
|
||||||
"ui": {
|
"ui": {
|
||||||
"animated_background": true,
|
"animated_background": false,
|
||||||
"public_remote_enabled": false,
|
"public_remote_enabled": false,
|
||||||
"public_remote_hosts": [],
|
"public_remote_hosts": [],
|
||||||
"theme": "dark"
|
"theme": "dark"
|
||||||
|
Loading…
Reference in New Issue
Block a user