in bicep/files-to-load/cyclecloud_install.py [0:0]
def start_cc():
import glob
import subprocess
print("(Re-)Starting CycleCloud server")
_catch_sys_error([cs_cmd, "stop"])
if glob.glob("/opt/cycle_server/data/ads/corrupt*") or glob.glob("/opt/cycle_server/data/ads/*logfile_failure"):
print("WARNING: Corrupted datastore masterlog detected. Restoring from last backup...")
if not glob.glob("/opt/cycle_server/data/backups/backup-*"):
raise Exception("ERROR: No backups found, but master.logfile is corrupt!")
try:
yes = subprocess.Popen(['echo', 'yes'], stdout=subprocess.PIPE)
output = subprocess.check_output(['/opt/cycle_server/util/restore.sh'], stdin=yes.stdout)
yes.wait()
print(output)
except CalledProcessError as e:
print("Error with cmd: %s" % e.cmd)
print("Output: %s" % e.output)
raise
_catch_sys_error([cs_cmd, "start"])
# Retry await_startup in case it takes much longer than expected
# (this is common in local testing with limited compute resources)
max_tries = 3
started = False
while not started:
try:
max_tries -= 1
_catch_sys_error([cs_cmd, "await_startup"])
started = True
except:
if max_tries > 0:
print("Retrying...")
else:
raise