mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
nextcloud: Wait on init sync lock
- First wait until the files are copied into /var/www/html from /usr/src/nextcloud. - Then wait until init-sync lock is released. - This allows for re-running setup as CAN_INSTALL file is removed after install process in completed. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
85cc9f08fa
commit
6e2db19a26
@ -61,16 +61,7 @@ def setup():
|
||||
env=env)
|
||||
action_utils.service_start(CONTAINER_NAME)
|
||||
|
||||
# OCC isn't immediately available after the container is spun up.
|
||||
# Wait until CAN_INSTALL file is available.
|
||||
timeout = 300
|
||||
while timeout > 0:
|
||||
if (_data_path / 'config/CAN_INSTALL').exists():
|
||||
break
|
||||
|
||||
timeout = timeout - 1
|
||||
time.sleep(1)
|
||||
|
||||
_nextcloud_wait_until_ready()
|
||||
_nextcloud_setup_wizard(database_password, administrator_password)
|
||||
_create_redis_config()
|
||||
|
||||
@ -178,6 +169,29 @@ def _set_database_privileges(db_password: str):
|
||||
_database_query(query)
|
||||
|
||||
|
||||
def _nextcloud_wait_until_ready():
|
||||
"""Wait for Nextcloud container to get ready."""
|
||||
# Nextcloud copies sources from /usr/src/nextcloud to /var/www/html inside
|
||||
# the container. Nextcloud is served from the latter location. This happens
|
||||
# on first run of the container and when upgrade happen.
|
||||
start_time = time.time()
|
||||
while time.time() < start_time + 300:
|
||||
if (_data_path / 'version.php').exists():
|
||||
break
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
# Wait while Nextcloud is syncing files, running install or performing an
|
||||
# upgrade by trying to obtain an exclusive on its init-sync.lock. Wrap the
|
||||
# echo command with the lock so that the lock is immediately released after
|
||||
# obtaining. We are unable to obtain the lock for 5 minutes, fail and stop
|
||||
# the setup process.
|
||||
lock_file = _data_path / 'nextcloud-init-sync.lock'
|
||||
subprocess.run(
|
||||
['flock', '--exclusive', '--wait', '300', lock_file, 'echo'],
|
||||
check=True)
|
||||
|
||||
|
||||
def _nextcloud_get_status():
|
||||
"""Return Nextcloud status such installed, in maintenance, etc."""
|
||||
output = _run_occ('status', '--output=json', capture_output=True)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user