mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
nextcloud: Restart container when dependent services are restarted
This is required because when services are restarted, their Unix domain sockets are removed and new ones are created. The container will still be using the old sockets and will fail to connect to the service. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
6b046ec27d
commit
614bea4511
@ -491,7 +491,8 @@ def is_package_manager_busy():
|
||||
|
||||
def podman_create(container_name: str, image_name: str, volume_name: str,
|
||||
volume_path: str, volumes: dict[str, str] | None = None,
|
||||
env: dict[str, str] | None = None):
|
||||
env: dict[str, str] | None = None,
|
||||
binds_to: list[str] | None = None):
|
||||
"""Remove and recreate a podman container."""
|
||||
service_stop(f'{volume_name}-volume.service')
|
||||
service_stop(container_name)
|
||||
@ -526,9 +527,12 @@ Options=bind
|
||||
])
|
||||
env_lines = '\n'.join(
|
||||
[f'Environment={key}={value}' for key, value in (env or {}).items()])
|
||||
bind_lines = '\n'.join(f'BindsTo={service}\nAfter={service}'
|
||||
for service in (binds_to or []))
|
||||
contents = f'''[Unit]
|
||||
Requires=nextcloud-freedombox-volume.service
|
||||
After=nextcloud-freedombox-volume.service
|
||||
{bind_lines}
|
||||
|
||||
[Container]
|
||||
AutoUpdate=registry
|
||||
|
||||
@ -52,10 +52,11 @@ def setup():
|
||||
VOLUME_NAME: '/var/www/html'
|
||||
}
|
||||
env = {'OVERWRITEWEBROOT': '/nextcloud'}
|
||||
binds_to = ['mariadb.service', 'redis-server.service', 'slapd.service']
|
||||
action_utils.podman_create(container_name=CONTAINER_NAME,
|
||||
image_name=IMAGE_NAME, volume_name=VOLUME_NAME,
|
||||
volume_path=str(_data_path), volumes=volumes,
|
||||
env=env)
|
||||
env=env, binds_to=binds_to)
|
||||
action_utils.service_start(CONTAINER_NAME)
|
||||
|
||||
_nextcloud_wait_until_ready()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user