send shutdown signal to tor
This commit is contained in:
parent
2bad1b30d2
commit
8070b3b8a9
1 changed files with 13 additions and 3 deletions
12
oml/tor.py
12
oml/tor.py
|
@ -9,6 +9,7 @@ import zipfile
|
|||
|
||||
import ox
|
||||
import stem
|
||||
from stem import Signal
|
||||
from stem.control import Controller
|
||||
from Crypto.PublicKey import RSA
|
||||
import settings
|
||||
|
@ -83,6 +84,13 @@ DirReqStatistics 0
|
|||
cmd += self.geoip(tor)
|
||||
cwd = os.path.dirname(tor)
|
||||
while self.running:
|
||||
if sys.platform == 'win32':
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||
self.p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1,
|
||||
universal_newlines=True, start_new_session=True, env=env, cwd=cwd, startupinfo=startupinfo)
|
||||
else:
|
||||
self.p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1,
|
||||
universal_newlines=True, start_new_session=True, env=env, cwd=cwd)
|
||||
for line in self.p.stdout:
|
||||
|
@ -171,12 +179,14 @@ class Tor(object):
|
|||
logger.debug('unknonw change %s', status)
|
||||
|
||||
def event_listener(self, event):
|
||||
print('EVENT', event)
|
||||
logger.debug('EVENT', event)
|
||||
|
||||
def shutdown(self):
|
||||
self._shutdown = True
|
||||
try:
|
||||
self.depublish()
|
||||
if self.daemon and self.controller:
|
||||
self.controller.signal(Signal.SHUTDOWN)
|
||||
if self.controller:
|
||||
#self.controller.remove_event_listener(self.connection_change)
|
||||
self.controller.close()
|
||||
|
|
Loading…
Reference in a new issue