from__future__importannotations# For type hinting before definition, ref: https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel
ifself.svcMgrThread:# if sig handler hasn't destroyed it by now
ifself.svcMgrThread:# if sig handler hasn't destroyed it by now
self.stopTaosService()# should have started already
self.stopTaosService()# should have started already
classServiceManagerThread:
classServiceManagerThread:
MAX_QUEUE_SIZE=10000
MAX_QUEUE_SIZE=10000
...
@@ -1788,9 +2035,9 @@ class ServiceManagerThread:
...
@@ -1788,9 +2035,9 @@ class ServiceManagerThread:
# Start the thread (with sub process), and wait for the sub service
# Start the thread (with sub process), and wait for the sub service
# to become fully operational
# to become fully operational
defstart(self):
defstart(self):
ifself._thread:
ifself._thread:
raiseRuntimeError("Unexpected _thread")
raiseRuntimeError("Unexpected _thread")
ifself._tdeSubProcess:
ifself._tdeSubProcess:
raiseRuntimeError("TDengine sub process already created/running")
raiseRuntimeError("TDengine sub process already created/running")
self._status=MainExec.STATUS_STARTING
self._status=MainExec.STATUS_STARTING
...
@@ -1806,14 +2053,15 @@ class ServiceManagerThread:
...
@@ -1806,14 +2053,15 @@ class ServiceManagerThread:
self._thread.start()
self._thread.start()
# wait for service to start
# wait for service to start
foriinrange(0,10):
foriinrange(0,10):
time.sleep(1.0)
time.sleep(1.0)
# self.procIpcBatch() # don't pump message during start up
# self.procIpcBatch() # don't pump message during start up
print("_zz_",end="",flush=True)
print("_zz_",end="",flush=True)
ifself._status==MainExec.STATUS_RUNNING:
ifself._status==MainExec.STATUS_RUNNING:
logger.info("[] TDengine service READY to process requests")
logger.info("[] TDengine service READY to process requests")
return# now we've started
return# now we've started
raiseRuntimeError("TDengine service did not start successfully")# TODO: handle this better?
# TODO: handle this better?
raiseRuntimeError("TDengine service did not start successfully")
defstop(self):
defstop(self):
# can be called from both main thread or signal handler
# can be called from both main thread or signal handler
...
@@ -1824,15 +2072,19 @@ class ServiceManagerThread:
...
@@ -1824,15 +2072,19 @@ class ServiceManagerThread:
ifself.isStopping():
ifself.isStopping():
print("Service is already being stopped")
print("Service is already being stopped")
return
return
# Linux will send Control-C generated SIGINT to the TDengine process already, ref: https://unix.stackexchange.com/questions/176235/fork-and-how-signals-are-delivered-to-processes
# Linux will send Control-C generated SIGINT to the TDengine process