mirror of https://gitlab.com/bashrc2/epicyon
Change GET benchmarks
parent
c0f4f502c5
commit
302bda9aa1
224
daemon.py
224
daemon.py
|
@ -849,13 +849,22 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_header('X-Robots-Tag','noindex')
|
||||
self.end_headers()
|
||||
|
||||
def _benchmarkGET(self,GETstartTime):
|
||||
def _benchmarkGETtimings(self,GETstartTime,GETtimings: [],getID: int):
|
||||
"""Updates a list containing how long each segment of GET takes
|
||||
"""
|
||||
if self.server.debug:
|
||||
timeDiff=str(int((time.time()-GETstartTime)*1000))
|
||||
timeDiffLen=len(timeDiff)
|
||||
for i in range(6-timeDiffLen):
|
||||
timeDiff='0'+timeDiff
|
||||
print('BENCHMARK GET|'+timeDiff+'|'+self.path)
|
||||
timeDiff=int((time.time()-GETstartTime)*1000)
|
||||
logEvent=False
|
||||
if timeDiff>100:
|
||||
logEvent=True
|
||||
if GETtimings:
|
||||
timeDiff=int(timeDiff-int(GETtimings[-1]))
|
||||
GETtimings.append(str(timeDiff))
|
||||
if logEvent:
|
||||
ctr=1
|
||||
for timeDiff in GETtimings:
|
||||
print('GET TIMING|'+str(ctr)+'|'+timeDiff)
|
||||
ctr+=1
|
||||
|
||||
def _benchmarkPOSTtimings(self,POSTstartTime,POSTtimings: [],postID: int):
|
||||
"""Updates a list containing how long each segment of POST takes
|
||||
|
@ -876,26 +885,30 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
def do_GET(self):
|
||||
GETstartTime=time.time()
|
||||
GETtimings=[]
|
||||
|
||||
# Since fediverse crawlers are quite active, make returning info to them high priority
|
||||
# get nodeinfo endpoint
|
||||
if self._nodeinfo():
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,1)
|
||||
|
||||
# minimal mastodon api
|
||||
if self._mastoApi():
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,2)
|
||||
|
||||
if self.path=='/logout':
|
||||
msg=htmlLogin(self.server.translate, \
|
||||
self.server.baseDir,False).encode('utf-8')
|
||||
self._logout_headers('text/html',len(msg))
|
||||
self._write(msg)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,3)
|
||||
|
||||
# replace https://domain/@nick with https://domain/users/nick
|
||||
if self.path.startswith('/@'):
|
||||
self.path=self.path.replace('/@','/users/')
|
||||
|
@ -916,6 +929,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self.headers.get('Cookie'):
|
||||
cookie=self.headers['Cookie']
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,4)
|
||||
|
||||
# check authorization
|
||||
authorized = self._isAuthorized()
|
||||
if authorized:
|
||||
|
@ -925,11 +940,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if self.server.debug:
|
||||
print('GET Not authorized')
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,5)
|
||||
|
||||
if not self.server.session:
|
||||
print('Starting new session')
|
||||
self.server.session= \
|
||||
createSession(self.server.useTor)
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,6)
|
||||
|
||||
# is this a html request?
|
||||
htmlGET=False
|
||||
if self.headers.get('Accept'):
|
||||
|
@ -937,9 +956,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
htmlGET=True
|
||||
else:
|
||||
self._400()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,7)
|
||||
|
||||
# treat shared inbox paths consistently
|
||||
if self.path=='/sharedInbox' or \
|
||||
self.path=='/users/inbox' or \
|
||||
|
@ -952,6 +972,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
self.path='/inbox'
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,8)
|
||||
|
||||
# show the person options screen with view/follow/block/report
|
||||
if htmlGET and '/users/' in self.path:
|
||||
if '?options=' in self.path:
|
||||
|
@ -982,12 +1004,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
pageNumber,donateUrl).encode()
|
||||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._redirect_headers(originPathStr,cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,9)
|
||||
|
||||
# remove a shared item
|
||||
if htmlGET and '?rmshare=' in self.path:
|
||||
shareName=self.path.split('?rmshare=')[1]
|
||||
|
@ -1000,36 +1022,39 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actor,shareName).encode()
|
||||
if not msg:
|
||||
self._redirect_headers(actor+'/inbox',cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,10)
|
||||
|
||||
if self.path.startswith('/terms'):
|
||||
msg=htmlTermsOfService(self.server.baseDir, \
|
||||
self.server.httpPrefix, \
|
||||
self.server.domainFull).encode()
|
||||
self._login_headers('text/html',len(msg))
|
||||
self._write(msg)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,11)
|
||||
|
||||
if self.path.startswith('/about'):
|
||||
msg=htmlAbout(self.server.baseDir, \
|
||||
self.server.httpPrefix, \
|
||||
self.server.domainFull).encode()
|
||||
self._login_headers('text/html',len(msg))
|
||||
self._write(msg)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,12)
|
||||
|
||||
# send robots.txt if asked
|
||||
if self._robotsTxt():
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,13)
|
||||
|
||||
# if not authorized then show the login screen
|
||||
if htmlGET and self.path!='/login' and self.path!='/':
|
||||
if '/media/' not in self.path and \
|
||||
|
@ -1061,9 +1086,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_header('Content-Length', '0')
|
||||
self.send_header('X-Robots-Tag','noindex')
|
||||
self.end_headers()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,14)
|
||||
|
||||
# get css
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if self.path.endswith('.css'):
|
||||
|
@ -1081,12 +1107,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
msg=css.encode('utf-8')
|
||||
self._set_headers('text/css',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,15)
|
||||
|
||||
# image on login screen
|
||||
if self.path=='/login.png' or \
|
||||
self.path=='/login.gif' or \
|
||||
|
@ -1110,12 +1136,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if mediaBinary:
|
||||
self._set_headers('image/png',len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,16)
|
||||
|
||||
# login screen background image
|
||||
if self.path=='/login-background.png':
|
||||
mediaFilename= \
|
||||
|
@ -1135,12 +1161,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if mediaBinary:
|
||||
self._set_headers('image/png',len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,17)
|
||||
|
||||
# follow screen background image
|
||||
if self.path=='/follow-background.png':
|
||||
mediaFilename= \
|
||||
|
@ -1160,12 +1186,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if mediaBinary:
|
||||
self._set_headers('image/png',len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,18)
|
||||
|
||||
# emoji images
|
||||
if '/emoji/' in self.path:
|
||||
if self.path.endswith('.png') or \
|
||||
|
@ -1188,12 +1214,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
mediaBinary = avFile.read()
|
||||
self._set_headers('image/'+mediaImageType,len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,19)
|
||||
|
||||
# show media
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if '/media/' in self.path:
|
||||
|
@ -1230,12 +1256,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
mediaBinary = avFile.read()
|
||||
self._set_headers(mediaFileType,len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,20)
|
||||
|
||||
# show shared item images
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if '/sharefiles/' in self.path:
|
||||
|
@ -1260,12 +1286,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
mediaBinary = avFile.read()
|
||||
self._set_headers('image/'+mediaFileType,len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,21)
|
||||
|
||||
# icon images
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if self.path.startswith('/icons/'):
|
||||
|
@ -1279,12 +1305,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
mediaBinary = avFile.read()
|
||||
self._set_headers('image/png',len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,22)
|
||||
|
||||
# cached avatar images
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if self.path.startswith('/avatars/'):
|
||||
|
@ -1303,15 +1329,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
# default to jpeg
|
||||
self._set_headers('image/jpeg',len(mediaBinary),cookie)
|
||||
#self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,23)
|
||||
|
||||
# show avatar or background image
|
||||
# Note that this comes before the busy flag to avoid conflicts
|
||||
if '/users/' in self.path:
|
||||
|
@ -1342,9 +1367,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('image/'+mediaImageType, \
|
||||
len(mediaBinary),cookie)
|
||||
self._write(mediaBinary)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,24)
|
||||
|
||||
# This busy state helps to avoid flooding
|
||||
# Resources which are expected to be called from a web page
|
||||
# should be above this
|
||||
|
@ -1355,24 +1381,25 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
print('DEBUG: GET Busy')
|
||||
self.send_response(429)
|
||||
self.end_headers()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self.server.lastGET=currTimeGET
|
||||
self.server.GETbusy=True
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,25)
|
||||
|
||||
if not self._permittedDir(self.path):
|
||||
if self.server.debug:
|
||||
print('DEBUG: GET Not permitted')
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
# get webfinger endpoint for a person
|
||||
if self._webfinger():
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,26)
|
||||
|
||||
if self.path.startswith('/login') or \
|
||||
(self.path=='/' and not authorized):
|
||||
# request basic auth
|
||||
|
@ -1381,9 +1408,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._login_headers('text/html',len(msg))
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,27)
|
||||
|
||||
# hashtag search
|
||||
if self.path.startswith('/tags/'):
|
||||
pageNumber=1
|
||||
|
@ -1399,7 +1427,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._login_headers('text/html',len(msg))
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
hashtagStr= \
|
||||
htmlHashtagSearch(self.server.translate, \
|
||||
|
@ -1417,9 +1444,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
originPathStr=self.path.split('/tags/')[0]
|
||||
self._redirect_headers(originPathStr+'/search',cookie)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,28)
|
||||
|
||||
# search for a fediverse address, shared item or emoji
|
||||
# from the web interface by selecting search icon
|
||||
if htmlGET and '/users/' in self.path:
|
||||
|
@ -1430,9 +1458,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,29)
|
||||
|
||||
# Show the calendar for a user
|
||||
if htmlGET and '/users/' in self.path:
|
||||
if '/calendar' in self.path:
|
||||
|
@ -1444,9 +1473,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,30)
|
||||
|
||||
# search for emoji by name
|
||||
if htmlGET and '/users/' in self.path:
|
||||
if self.path.endswith('/searchemoji'):
|
||||
|
@ -1457,9 +1487,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,31)
|
||||
|
||||
# announce/repeat from the web interface
|
||||
if htmlGET and '?repeat=' in self.path:
|
||||
pageNumber=1
|
||||
|
@ -1484,7 +1515,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+ \
|
||||
'?page='+str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
if not self.server.session:
|
||||
self.server.session= \
|
||||
|
@ -1510,9 +1540,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+'?page='+ \
|
||||
str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,32)
|
||||
|
||||
# undo an announce/repeat from the web interface
|
||||
if htmlGET and '?unrepeat=' in self.path:
|
||||
pageNumber=1
|
||||
|
@ -1537,7 +1568,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+'?page='+ \
|
||||
str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
if not self.server.session:
|
||||
self.server.session= \
|
||||
|
@ -1563,9 +1593,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+'?page='+ \
|
||||
str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,33)
|
||||
|
||||
# send a follow request approval from the web interface
|
||||
if authorized and '/followapprove=' in self.path and \
|
||||
self.path.startswith('/users/'):
|
||||
|
@ -1593,9 +1624,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.projectVersion)
|
||||
self._redirect_headers(originPathStr,cookie)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,34)
|
||||
|
||||
# deny a follow request from the web interface
|
||||
if authorized and '/followdeny=' in self.path and \
|
||||
self.path.startswith('/users/'):
|
||||
|
@ -1619,9 +1651,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.projectVersion)
|
||||
self._redirect_headers(originPathStr,cookie)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,35)
|
||||
|
||||
# like from the web interface icon
|
||||
if htmlGET and '?like=' in self.path:
|
||||
pageNumber=1
|
||||
|
@ -1647,7 +1680,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+ \
|
||||
'?page='+str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
if not self.server.session:
|
||||
self.server.session= \
|
||||
|
@ -1669,9 +1701,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+ \
|
||||
'?page='+str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,36)
|
||||
|
||||
# undo a like from the web interface icon
|
||||
if htmlGET and '?unlike=' in self.path:
|
||||
pageNumber=1
|
||||
|
@ -1696,7 +1729,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+ \
|
||||
'?page='+str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
if not self.server.session:
|
||||
self.server.session= \
|
||||
|
@ -1723,9 +1755,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy=False
|
||||
self._redirect_headers(actor+'/'+timelineStr+ \
|
||||
'?page='+str(pageNumber),cookie)
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,37)
|
||||
|
||||
# delete a post from the web interface icon
|
||||
if htmlGET and '?delete=' in self.path:
|
||||
pageNumber=1
|
||||
|
@ -1749,14 +1782,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if actor not in deleteUrl:
|
||||
# You can only delete your own posts
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
self._redirect_headers(actor+'/inbox',cookie)
|
||||
return
|
||||
self.postToNickname=getNicknameFromActor(actor)
|
||||
if not self.postToNickname:
|
||||
print('WARN: unable to find nickname in '+actor)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
self._redirect_headers(actor+'/inbox',cookie)
|
||||
return
|
||||
if not self.server.session:
|
||||
|
@ -1773,10 +1804,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(deleteStr),cookie)
|
||||
self._write(deleteStr.encode())
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
self._redirect_headers(actor+'/inbox',cookie)
|
||||
return
|
||||
|
||||
|
@ -1863,7 +1892,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
# Various types of new post in the web interface
|
||||
|
@ -1883,9 +1911,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,38)
|
||||
|
||||
# get an individual post from the path /@nickname/statusnumber
|
||||
if '/@' in self.path:
|
||||
namedStatus=self.path.split('/@')[1]
|
||||
|
@ -1938,14 +1967,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,39)
|
||||
|
||||
# get replies to a post /users/nickname/statuses/number/replies
|
||||
if self.path.endswith('/replies') or '/replies?page=' in self.path:
|
||||
if '/statuses/' in self.path and '/users/' in self.path:
|
||||
|
@ -2005,7 +2034,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
# replies exist. Itterate through the text file containing message ids
|
||||
|
@ -2053,9 +2081,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,40)
|
||||
|
||||
if self.path.endswith('/roles') and '/users/' in self.path:
|
||||
namedStatus=self.path.split('/users/')[1]
|
||||
if '/' in namedStatus:
|
||||
|
@ -2096,7 +2125,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
# show skills on the profile page
|
||||
|
@ -2140,14 +2168,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
actor=self.path.replace('/skills','')
|
||||
self._benchmarkGET(GETstartTime)
|
||||
self._redirect_headers(actor,cookie)
|
||||
self.server.GETbusy=False
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,41)
|
||||
|
||||
# get an individual post from the path /users/nickname/statuses/number
|
||||
if '/statuses/' in self.path and '/users/' in self.path:
|
||||
namedStatus=self.path.split('/users/')[1]
|
||||
|
@ -2169,7 +2197,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_response(429)
|
||||
self.end_headers()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
# Only authorized viewers get to see likes on posts
|
||||
|
@ -2199,14 +2226,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,42)
|
||||
|
||||
# get the inbox for a given person
|
||||
if self.path.endswith('/inbox') or '/inbox?page=' in self.path:
|
||||
if '/users/' in self.path:
|
||||
|
@ -2262,7 +2289,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('application/json',len(msg),None)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self.server.debug:
|
||||
|
@ -2276,9 +2302,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_response(405)
|
||||
self.end_headers()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,43)
|
||||
|
||||
# get the direct messages for a given person
|
||||
if self.path.endswith('/dm') or '/dm?page=' in self.path:
|
||||
if '/users/' in self.path:
|
||||
|
@ -2334,7 +2361,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('application/json',len(msg),None)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self.server.debug:
|
||||
|
@ -2348,9 +2374,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_response(405)
|
||||
self.end_headers()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,44)
|
||||
|
||||
# get the replies for a given person
|
||||
if self.path.endswith('/tlreplies') or '/tlreplies?page=' in self.path:
|
||||
if '/users/' in self.path:
|
||||
|
@ -2409,7 +2436,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('application/json',len(msg),None)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self.server.debug:
|
||||
|
@ -2423,9 +2449,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_response(405)
|
||||
self.end_headers()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,45)
|
||||
|
||||
# get the media for a given person
|
||||
if self.path.endswith('/tlmedia') or '/tlmedia?page=' in self.path:
|
||||
if '/users/' in self.path:
|
||||
|
@ -2484,7 +2511,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('application/json',len(msg),None)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self.server.debug:
|
||||
|
@ -2498,9 +2524,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_response(405)
|
||||
self.end_headers()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,46)
|
||||
|
||||
# get the shared items timeline for a given person
|
||||
if self.path.endswith('/tlshares') or '/tlshares?page=' in self.path:
|
||||
if '/users/' in self.path:
|
||||
|
@ -2530,7 +2557,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
# not the shares timeline
|
||||
if self.server.debug:
|
||||
|
@ -2538,9 +2564,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_response(405)
|
||||
self.end_headers()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,47)
|
||||
|
||||
# get outbox feed for a person
|
||||
outboxFeed=personBoxJson(self.server.session, \
|
||||
self.server.baseDir,self.server.domain, \
|
||||
|
@ -2595,9 +2622,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,48)
|
||||
|
||||
# get the moderation feed for a moderator
|
||||
if self.path.endswith('/moderation') or \
|
||||
'/moderation?page=' in self.path:
|
||||
|
@ -2657,7 +2685,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('application/json',len(msg),None)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self.server.debug:
|
||||
|
@ -2669,9 +2696,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.send_response(405)
|
||||
self.end_headers()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,49)
|
||||
|
||||
shares=getSharesFeedForPerson(self.server.baseDir, \
|
||||
self.server.domain, \
|
||||
self.server.port,self.path, \
|
||||
|
@ -2720,7 +2748,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
|
@ -2730,9 +2757,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,50)
|
||||
|
||||
following=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
||||
self.server.port,self.path, \
|
||||
self.server.httpPrefix, \
|
||||
|
@ -2776,7 +2804,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
|
@ -2786,8 +2813,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,51)
|
||||
|
||||
followers=getFollowingFeed(self.server.baseDir,self.server.domain, \
|
||||
self.server.port,self.path, \
|
||||
self.server.httpPrefix, \
|
||||
|
@ -2832,7 +2861,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
|
@ -2842,8 +2870,10 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,52)
|
||||
|
||||
# look up a person
|
||||
getPerson = personLookup(self.server.domain,self.path, \
|
||||
self.server.baseDir)
|
||||
|
@ -2875,24 +2905,26 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,53)
|
||||
|
||||
# check that a json file was requested
|
||||
if not self.path.endswith('.json'):
|
||||
if self.server.debug:
|
||||
print('DEBUG: GET Not json: '+self.path+' '+self.server.baseDir)
|
||||
self._404()
|
||||
self.server.GETbusy=False
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
if not self._fetchAuthenticated():
|
||||
if self.server.debug:
|
||||
print('WARN: Unauthenticated GET')
|
||||
self._404()
|
||||
self._benchmarkGET(GETstartTime)
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,54)
|
||||
|
||||
# check that the file exists
|
||||
filename=self.server.baseDir+self.path
|
||||
if os.path.isfile(filename):
|
||||
|
@ -2908,6 +2940,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._404()
|
||||
self.server.GETbusy=False
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime,GETtimings,55)
|
||||
|
||||
def do_HEAD(self):
|
||||
self._set_headers('application/json',0,None)
|
||||
|
||||
|
|
|
@ -4,12 +4,15 @@ if [ -d /etc/epicyon ]; then
|
|||
else
|
||||
cd /opt/epicyon || exit 0
|
||||
fi
|
||||
journalctl -u epicyon -r | grep "BENCHMARK GET|0\|BENCHMARK POST|0" | head -n 50 | grep "|ID" | awk -F 'BENCHMARK' '{print $2}' | sort -r | uniq | head -n 20
|
||||
|
||||
echo ''
|
||||
echo 'Digest calculation times'
|
||||
journalctl -u epicyon | grep "DIGEST|" | awk -F '|' '{print $2}' | sort -r | uniq | head -n 20
|
||||
|
||||
echo ''
|
||||
echo 'Timings for GET'
|
||||
journalctl -u epicyon -r | grep "GET TIMING|" | head -n 50
|
||||
|
||||
echo ''
|
||||
echo 'Timings for POST'
|
||||
journalctl -u epicyon -r | grep "POST TIMING|" | head -n 50
|
||||
|
|
Loading…
Reference in New Issue