Skip to content

Commit

Permalink
Upd ver
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Dec 28, 2024
1 parent ce72e73 commit bff7561
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
15 changes: 11 additions & 4 deletions lib/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,24 @@ async def version(cls) -> Tuple[int, int, int]:

@classmethod
async def pull_and_update(cls):
services = await cls.services()
services = await cls.services(all_services=True)
services = set(services)
services.remove('rapp')
for service_name in ('rapp', 'watchtower', 'socat'):
try:
services.remove(service_name)
except KeyError:
pass
services = ' '.join(services)
async with cls.lock:
await cls._run(f'{COMPOSE_CMD} pull {services}')
await cls._run(f'{COMPOSE_CMD} up -d {services} --remove-orphans')

@classmethod
async def services(cls, running: bool = False) -> List[str]:
status = ' --status running' if running else ''
async def services(cls,
running: bool = False,
all_services: bool = False) -> List[str]:
status = ' --status running' if running else (
' --all' if all_services else '')
async with cls.lock:
out, _ = await cls._run(
f'{COMPOSE_CMD} ps --services{status}')
Expand Down
3 changes: 1 addition & 2 deletions lib/envvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
CONFIG_FILE = os.getenv('CONFIG_FILE', '/config/infrasonar.yaml')
COMPOSE_PATH = os.path.dirname(COMPOSE_FILE)
USE_DEVELOPMENT = bool(int(os.getenv('USE_DEVELOPMENT', '0')))
PROJECT_NAME = os.getenv('PROJECT_NAME', 'infrasonar')
COMPOSE_CMD = f'docker compose -p {PROJECT_NAME} --progress plain'
COMPOSE_CMD = 'docker compose --progress plain'
8 changes: 8 additions & 0 deletions lib/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,3 +577,11 @@ def init(cls):
# Test docker version
docker_version = cls.loop.run_until_complete(Docker.version())
logging.info(f'docker version: {docker_version}')

# Test docker mount (no services found when path does not match)
services = cls.loop.run_until_complete(Docker.services())
if not services:
raise Exception(
'no docker services found; most likely the docker mount '
'does not reflect the path running on the host; make sure to '
'verify the COMPOSE_FILE matches the path on the host')
2 changes: 1 addition & 1 deletion lib/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0-alpha5'
__version__ = '0.1.0-alpha6'

0 comments on commit bff7561

Please sign in to comment.