mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-23 23:17:58 +00:00
Compare commits
No commits in common. "1d8de63d95d4fcd84a54d4c54a499242d04aa65c" and "10282560654c975c5a77aead3017035406372e53" have entirely different histories.
1d8de63d95
...
1028256065
10
relay.spec
10
relay.spec
|
@ -14,15 +14,7 @@ a = Analysis(
|
||||||
'aputils.errors',
|
'aputils.errors',
|
||||||
'aputils.misc',
|
'aputils.misc',
|
||||||
'aputils.objects',
|
'aputils.objects',
|
||||||
'aputils.signer',
|
'aputils.signer'
|
||||||
|
|
||||||
'tinysql.base',
|
|
||||||
'tinysql.database',
|
|
||||||
'tinysql.error',
|
|
||||||
'tinysql.mysql',
|
|
||||||
'tinysql.postgresql',
|
|
||||||
'tinysql.sqlite',
|
|
||||||
'tinysql.statement'
|
|
||||||
],
|
],
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
hooksconfig={},
|
hooksconfig={},
|
||||||
|
|
|
@ -14,7 +14,6 @@ from datetime import datetime, timedelta
|
||||||
from .config import Config
|
from .config import Config
|
||||||
from .database import Database
|
from .database import Database
|
||||||
from .http_client import HttpClient
|
from .http_client import HttpClient
|
||||||
from .logger import set_level
|
|
||||||
from .misc import DotDict, check_open_port, set_app
|
from .misc import DotDict, check_open_port, set_app
|
||||||
from .views import routes
|
from .views import routes
|
||||||
|
|
||||||
|
@ -42,9 +41,6 @@ class Application(web.Application):
|
||||||
self.database.create()
|
self.database.create()
|
||||||
self.set_signal_handler()
|
self.set_signal_handler()
|
||||||
|
|
||||||
with self.database.session as s:
|
|
||||||
set_level(s.get_config('log_level'))
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def client(self):
|
def client(self):
|
||||||
|
@ -117,7 +113,6 @@ class Application(web.Application):
|
||||||
|
|
||||||
logging.info(f'Starting webserver at {self.config.host} ({self.config.listen}:{self.config.port})')
|
logging.info(f'Starting webserver at {self.config.host} ({self.config.listen}:{self.config.port})')
|
||||||
asyncio.run(self.handle_run())
|
asyncio.run(self.handle_run())
|
||||||
self.database.disconnect()
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self, *_):
|
def stop(self, *_):
|
||||||
|
|
|
@ -4,7 +4,6 @@ from datetime import datetime
|
||||||
from tinysql import Column, Table
|
from tinysql import Column, Table
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from .logger import set_level
|
|
||||||
from .misc import AppBase, DotDict, boolean
|
from .misc import AppBase, DotDict, boolean
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,7 +186,7 @@ class Connection(tinysql.ConnectionMixin):
|
||||||
|
|
||||||
query = 'SELECT * FROM instances WHERE domain = :data OR actor = :data OR inbox = :data'
|
query = 'SELECT * FROM instances WHERE domain = :data OR actor = :data OR inbox = :data'
|
||||||
row = self.execute(query, dict(data=data), table='instances').one()
|
row = self.execute(query, dict(data=data), table='instances').one()
|
||||||
return row if row and row.joined else None
|
return row if row.joined else None
|
||||||
|
|
||||||
|
|
||||||
def get_instances(self):
|
def get_instances(self):
|
||||||
|
@ -246,9 +245,6 @@ class Connection(tinysql.ConnectionMixin):
|
||||||
if value == '__DEFAULT__':
|
if value == '__DEFAULT__':
|
||||||
value = DEFAULT_CONFIG[key][1]
|
value = DEFAULT_CONFIG[key][1]
|
||||||
|
|
||||||
if key == 'log_level':
|
|
||||||
set_level(value)
|
|
||||||
|
|
||||||
row = self.select('config', key=key).one()
|
row = self.select('config', key=key).one()
|
||||||
|
|
||||||
if row:
|
if row:
|
||||||
|
|
|
@ -4,16 +4,6 @@ import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
LEVELS = {
|
|
||||||
'critical': logging.CRITICAL,
|
|
||||||
'error': logging.ERROR,
|
|
||||||
'warning': logging.WARNING,
|
|
||||||
'info': logging.INFO,
|
|
||||||
'verbose': 15,
|
|
||||||
'debug': logging.DEBUG
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Add the verbose logging level
|
## Add the verbose logging level
|
||||||
def verbose(message, *args, **kwargs):
|
def verbose(message, *args, **kwargs):
|
||||||
if not logging.root.isEnabledFor(logging.VERBOSE):
|
if not logging.root.isEnabledFor(logging.VERBOSE):
|
||||||
|
@ -25,6 +15,10 @@ setattr(logging, 'verbose', verbose)
|
||||||
setattr(logging, 'VERBOSE', 15)
|
setattr(logging, 'VERBOSE', 15)
|
||||||
logging.addLevelName(15, 'VERBOSE')
|
logging.addLevelName(15, 'VERBOSE')
|
||||||
|
|
||||||
|
|
||||||
|
## Get log level and file from environment if possible
|
||||||
|
env_log_level = os.environ.get('LOG_LEVEL', 'INFO').upper()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
env_log_file = Path(os.environ.get('LOG_FILE')).expanduser().resolve()
|
env_log_file = Path(os.environ.get('LOG_FILE')).expanduser().resolve()
|
||||||
|
|
||||||
|
@ -32,6 +26,14 @@ except TypeError:
|
||||||
env_log_file = None
|
env_log_file = None
|
||||||
|
|
||||||
|
|
||||||
|
## Make sure the level from the environment is valid
|
||||||
|
try:
|
||||||
|
log_level = getattr(logging, env_log_level)
|
||||||
|
|
||||||
|
except AttributeError:
|
||||||
|
log_level = logging.INFO
|
||||||
|
|
||||||
|
|
||||||
## Set logging config
|
## Set logging config
|
||||||
handlers = [logging.StreamHandler()]
|
handlers = [logging.StreamHandler()]
|
||||||
|
|
||||||
|
@ -39,11 +41,7 @@ if env_log_file:
|
||||||
handlers.append(logging.FileHandler(env_log_file))
|
handlers.append(logging.FileHandler(env_log_file))
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level = logging.INFO,
|
level = log_level,
|
||||||
format = "[%(asctime)s] %(levelname)s: %(message)s",
|
format = "[%(asctime)s] %(levelname)s: %(message)s",
|
||||||
handlers = handlers
|
handlers = handlers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def set_level(level):
|
|
||||||
logging.getLogger().setLevel(LEVELS[level.lower()])
|
|
||||||
|
|
|
@ -4,4 +4,4 @@ aputils@https://git.barkshark.xyz/barkshark/aputils/archive/0.1.3.tar.gz
|
||||||
cachetools>=5.2.0
|
cachetools>=5.2.0
|
||||||
click>=8.1.2
|
click>=8.1.2
|
||||||
pyyaml>=6.0
|
pyyaml>=6.0
|
||||||
tinysql[postgres,mysql]@https://git.barkshark.xyz/barkshark/tinysql/archive/0.1.0.tar.gz
|
tinysql[postgres,mysql]@https:/git.barkshark.xyz/barkshark/tinysql/archive/0.1.0.tar.gz
|
||||||
|
|
Loading…
Reference in a new issue