mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-12-22 19:21:08 +00:00
fix running via docker
This commit is contained in:
parent
b85b4ab80b
commit
15b314922c
|
@ -21,8 +21,7 @@ class Application(web.Application):
|
|||
|
||||
self['starttime'] = None
|
||||
self['running'] = False
|
||||
self['is_docker'] = bool(os.environ.get('DOCKER_RUNNING'))
|
||||
self['config'] = RelayConfig(cfgpath, self['is_docker'])
|
||||
self['config'] = RelayConfig(cfgpath)
|
||||
|
||||
if not self['config'].load():
|
||||
self['config'].save()
|
||||
|
@ -59,11 +58,6 @@ class Application(web.Application):
|
|||
return self['database']
|
||||
|
||||
|
||||
@property
|
||||
def is_docker(self):
|
||||
return self['is_docker']
|
||||
|
||||
|
||||
@property
|
||||
def semaphore(self):
|
||||
return self['semaphore']
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import json
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from functools import cached_property
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
@ -25,22 +27,17 @@ class RelayConfig(DotDict):
|
|||
}
|
||||
|
||||
|
||||
def __init__(self, path, is_docker):
|
||||
def __init__(self, path):
|
||||
DotDict.__init__(self, {})
|
||||
|
||||
if is_docker:
|
||||
path = '/data/relay.yaml'
|
||||
if self.is_docker:
|
||||
path = '/data/config.yaml'
|
||||
|
||||
self._isdocker = is_docker
|
||||
self._path = Path(path).expanduser()
|
||||
|
||||
self.reset()
|
||||
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if self._isdocker and key in ['db', 'listen', 'port']:
|
||||
return
|
||||
|
||||
if key in ['blocked_instances', 'blocked_software', 'whitelist']:
|
||||
assert isinstance(value, (list, set, tuple))
|
||||
|
||||
|
@ -80,6 +77,11 @@ class RelayConfig(DotDict):
|
|||
return f'{self.actor}#main-key'
|
||||
|
||||
|
||||
@cached_property
|
||||
def is_docker(self):
|
||||
return bool(os.environ.get('DOCKER_RUNNING'))
|
||||
|
||||
|
||||
def reset(self):
|
||||
self.clear()
|
||||
self.update({
|
||||
|
@ -98,6 +100,13 @@ class RelayConfig(DotDict):
|
|||
'whitelist': []
|
||||
})
|
||||
|
||||
if self.is_docker:
|
||||
self.update({
|
||||
'db': Path('/data/relay.jsonld'),
|
||||
'listen': '127.0.0.1'
|
||||
})
|
||||
|
||||
|
||||
def ban_instance(self, instance):
|
||||
if instance.startswith('http'):
|
||||
instance = urlparse(instance).hostname
|
||||
|
|
|
@ -51,7 +51,7 @@ def cli_setup():
|
|||
|
||||
app.config.save()
|
||||
|
||||
if not app['is_docker'] and click.confirm('Relay all setup! Would you like to run it now?'):
|
||||
if not app.config.is_docker and click.confirm('Relay all setup! Would you like to run it now?'):
|
||||
cli_run.callback()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue