hopefully fully fixed FDs now
parent
11d9047548
commit
403150300e
|
@ -17,9 +17,10 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
from gevent.pywsgi import WSGIServer
|
||||
import gevent.monkey
|
||||
gevent.monkey.patch_socket()
|
||||
from gevent.pywsgi import WSGIServer, WSGIHandler
|
||||
from gevent import Timeout
|
||||
#import gevent.monkey
|
||||
#gevent.monkey.patch_socket()
|
||||
import flask, cgi
|
||||
from flask import request, Response, abort, send_from_directory
|
||||
import sys, random, threading, hmac, hashlib, base64, time, math, os, json, socket
|
||||
|
@ -27,6 +28,17 @@ import core
|
|||
from onionrblockapi import Block
|
||||
import onionrutils, onionrexceptions, onionrcrypto, blockimporter, onionrevents as events, logger, config, onionr
|
||||
|
||||
class FDSafeHandler(WSGIHandler):
|
||||
def handle(self):
|
||||
timeout = Timeout(10, exception=Exception)
|
||||
timeout.start()
|
||||
|
||||
#timeout = gevent.Timeout.start_new(3)
|
||||
try:
|
||||
WSGIHandler.handle(self)
|
||||
except Timeout as ex:
|
||||
raise
|
||||
|
||||
def guessMime(path):
|
||||
'''
|
||||
Guesses the mime type of a file from the input filename
|
||||
|
@ -221,7 +233,7 @@ class PublicAPI:
|
|||
clientAPI._core.refreshFirstStartVars()
|
||||
self.torAdder = clientAPI._core.hsAddress
|
||||
time.sleep(1)
|
||||
self.httpServer = WSGIServer((self.host, self.bindPort), app, log=None)
|
||||
self.httpServer = WSGIServer((self.host, self.bindPort), app, log=None, handler_class=FDSafeHandler)
|
||||
self.httpServer.serve_forever()
|
||||
|
||||
class API:
|
||||
|
@ -394,13 +406,14 @@ class API:
|
|||
|
||||
@app.route('/getstats')
|
||||
def getStats():
|
||||
return Response(self._core.serializer.getStats())
|
||||
return Response("disabled")
|
||||
#return Response(self._core.serializer.getStats())
|
||||
|
||||
@app.route('/getuptime')
|
||||
def showUptime():
|
||||
return Response(str(self.getUptime()))
|
||||
|
||||
self.httpServer = WSGIServer((self.host, bindPort), app, log=None)
|
||||
self.httpServer = WSGIServer((self.host, bindPort), app, log=None, handler_class=FDSafeHandler)
|
||||
self.httpServer.serve_forever()
|
||||
|
||||
def setPublicAPIInstance(self, inst):
|
||||
|
|
|
@ -97,7 +97,7 @@ class OnionrCommunicatorDaemon:
|
|||
# Set timers, function reference, seconds
|
||||
# requiresPeer True means the timer function won't fire if we have no connected peers
|
||||
peerPoolTimer = OnionrCommunicatorTimers(self, self.getOnlinePeers, 60, maxThreads=1)
|
||||
OnionrCommunicatorTimers(self, self.runCheck, 1)
|
||||
OnionrCommunicatorTimers(self, self.runCheck, 2, maxThreads=1)
|
||||
OnionrCommunicatorTimers(self, self.lookupBlocks, self._core.config.get('timers.lookupBlocks'), requiresPeer=True, maxThreads=1)
|
||||
OnionrCommunicatorTimers(self, self.getBlocks, self._core.config.get('timers.getBlocks'), requiresPeer=True, maxThreads=2)
|
||||
OnionrCommunicatorTimers(self, self.clearOfflinePeer, 58)
|
||||
|
|
|
@ -74,7 +74,7 @@ class DaemonTools:
|
|||
retData = True
|
||||
self.daemon._core.setAddressInfo(peer, 'introduced', 1)
|
||||
self.daemon._core.setAddressInfo(peer, 'powValue', data['random'])
|
||||
self.daemon.decrementThreadCount('announceNode')
|
||||
self.daemon.decrementThreadCount('announceNode')
|
||||
return retData
|
||||
|
||||
def netCheck(self):
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
"file": {
|
||||
"output": true,
|
||||
"path": "data/output.log"
|
||||
"path": "output.log"
|
||||
},
|
||||
|
||||
"console" : {
|
||||
|
|
Loading…
Reference in New Issue