forked from indymedia/epicyon
Archive daily
parent
8703f86c05
commit
8551e1e3a7
8
cache.py
8
cache.py
|
@ -66,14 +66,6 @@ def expirePersonCache(personCache: {}):
|
|||
del personCache[personUrl]
|
||||
print(str(len(removals))+' actors were expired from the cache')
|
||||
|
||||
def expireCache(baseDir: str,personCache: {}):
|
||||
"""Cache expiry thread
|
||||
"""
|
||||
while True:
|
||||
# once per day
|
||||
time.sleep(60*60*24)
|
||||
expirePersonCache(basedir,personCache)
|
||||
|
||||
def storeWebfingerInCache(handle: str,wf,cachedWebfingers: {}) -> None:
|
||||
"""Store a webfinger endpoint in the cache
|
||||
"""
|
||||
|
|
13
daemon.py
13
daemon.py
|
@ -43,6 +43,7 @@ from posts import createFollowersOnlyPost
|
|||
from posts import createDirectMessagePost
|
||||
from posts import populateRepliesJson
|
||||
from posts import addToField
|
||||
from posts import expireCache
|
||||
from inbox import inboxPermittedMessage
|
||||
from inbox import inboxMessageHasParams
|
||||
from inbox import runInboxQueue
|
||||
|
@ -109,7 +110,6 @@ from announce import createAnnounce
|
|||
from announce import outboxAnnounce
|
||||
from content import addHtmlTags
|
||||
from media import removeMetaData
|
||||
from cache import expireCache
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -2892,6 +2892,7 @@ def runDaemon(projectVersion, \
|
|||
# max POST size of 10M
|
||||
httpd.projectVersion=projectVersion
|
||||
httpd.maxPostLength=1024*1024*10
|
||||
httpd.maxPostsInBox=256
|
||||
httpd.domain=domain
|
||||
httpd.port=port
|
||||
httpd.domainFull=domain
|
||||
|
@ -2949,10 +2950,18 @@ def runDaemon(projectVersion, \
|
|||
print('Creating actors cache')
|
||||
os.mkdir(baseDir+'/cache/actors')
|
||||
|
||||
archiveDir=baseDir+'/archive'
|
||||
if not os.path.isdir(archiveDir):
|
||||
print('Creating archive')
|
||||
os.mkdir(archiveDir)
|
||||
|
||||
print('Creating cache expiry thread')
|
||||
httpd.thrCache= \
|
||||
threadWithTrace(target=expireCache, \
|
||||
args=(baseDir,httpd.personCache),daemon=True)
|
||||
args=(baseDir,httpd.personCache, \
|
||||
httpd.httpPrefix, \
|
||||
archiveDir, \
|
||||
httpdmaxPostsInBox),daemon=True)
|
||||
httpd.thrCache.start()
|
||||
|
||||
print('Creating inbox queue')
|
||||
|
|
10
posts.py
10
posts.py
|
@ -21,6 +21,7 @@ from collections import OrderedDict
|
|||
from threads import threadWithTrace
|
||||
from cache import storePersonInCache
|
||||
from cache import getPersonFromCache
|
||||
from cache import expirePersonCache
|
||||
from pprint import pprint
|
||||
from random import randint
|
||||
from session import createSession
|
||||
|
@ -1706,6 +1707,15 @@ def createBoxBase(baseDir: str,boxname: str, \
|
|||
return boxHeader
|
||||
return boxItems
|
||||
|
||||
def expireCache(baseDir: str,personCache: {},httpPrefix: str,archiveDir: str,maxPostsInBox=256):
|
||||
"""Thread used to expire actors from the cache and archive old posts
|
||||
"""
|
||||
while True:
|
||||
# once per day
|
||||
time.sleep(60*60*24)
|
||||
expirePersonCache(basedir,personCache)
|
||||
archivePosts(baseDir,httpPrefix,archiveDir,maxPostsInBox)
|
||||
|
||||
def archivePosts(baseDir: str,httpPrefix: str,archiveDir: str,maxPostsInBox=256) -> None:
|
||||
"""Archives posts for all accounts
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue