Launch minode in Main()
This commit is contained in:
parent
dff04be7bc
commit
3c870f6f8c
|
@ -21,6 +21,7 @@ app_dir = pathmagic.setup()
|
||||||
import depends
|
import depends
|
||||||
depends.check_dependencies()
|
depends.check_dependencies()
|
||||||
|
|
||||||
|
# import atexit
|
||||||
import ctypes
|
import ctypes
|
||||||
import getopt
|
import getopt
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
@ -220,9 +221,12 @@ class Main(object):
|
||||||
|
|
||||||
if os.getenv('BITMESSAGE_HYBRID'): # use objqueue of an external app
|
if os.getenv('BITMESSAGE_HYBRID'): # use objqueue of an external app
|
||||||
import queues
|
import queues
|
||||||
from tests import queue
|
from tests import launcher, queue
|
||||||
|
|
||||||
state.enableNetwork = False
|
state.enableNetwork = False
|
||||||
|
minode = launcher.MinodeProcess()
|
||||||
|
minode.start()
|
||||||
|
# atexit.register(minode.stop)
|
||||||
queues.objectProcessorQueue = queue.ObjQueue()
|
queues.objectProcessorQueue = queue.ObjQueue()
|
||||||
|
|
||||||
set_thread_name("PyBitmessage")
|
set_thread_name("PyBitmessage")
|
||||||
|
|
26
src/tests/launcher.py
Normal file
26
src/tests/launcher.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
"""Launching an external app with the network queue"""
|
||||||
|
|
||||||
|
import atexit
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
class MinodeProcess(object):
|
||||||
|
_process_cmd = [
|
||||||
|
'minode', '--no-incoming', '--msg-queue']
|
||||||
|
|
||||||
|
def __init__(self, port=8444, connection_limit=4):
|
||||||
|
self.port = str(port)
|
||||||
|
self.connection_limit = str(connection_limit)
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
cmd = self._process_cmd + [
|
||||||
|
'-p', self.port,
|
||||||
|
'--connection-limit', self.connection_limit
|
||||||
|
]
|
||||||
|
self.process = subprocess.Popen(cmd, stderr=subprocess.STDOUT)
|
||||||
|
atexit.register(self.stop)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.process.send_signal(signal.SIGTERM)
|
||||||
|
self.process.wait(10)
|
Reference in New Issue
Block a user