From 6901596f120463ad0353b29e663b73c38ad7d4e1 Mon Sep 17 00:00:00 2001 From: Michael Kamprath Date: Wed, 23 Sep 2020 11:03:55 -0700 Subject: [PATCH] adjusted upcloud timing Adjusted both the command timeout and the timing of when server commands are sent due to apparent changes on UpClouds side. Also addressed a bug that occurs of there is a space in the file path to the configuration file to be used. --- deployment-scripts/upcloud-deploy.py | 29 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/deployment-scripts/upcloud-deploy.py b/deployment-scripts/upcloud-deploy.py index 50baae2..8909f22 100644 --- a/deployment-scripts/upcloud-deploy.py +++ b/deployment-scripts/upcloud-deploy.py @@ -114,7 +114,7 @@ def print_help(): exit(2) # Connect to UpCloud -manager = up.CloudManager(upcloud_user, upcloud_password) +manager = up.CloudManager(upcloud_user, upcloud_password, timeout=60) manager.authenticate() print('Connected to UpCloud API as user "{0}"'.format(upcloud_user)) @@ -164,6 +164,10 @@ def print_help(): ) # wait for the server to finish booting and installing docker +print('Waiting 7 minutes for server set up to complete ...') +time.sleep(60) +print('Waiting 6 minutes for server set up to complete ...') +time.sleep(60) print('Waiting 5 minutes for server set up to complete ...') time.sleep(60) print('Waiting 4 minutes for server set up to complete ...') @@ -179,29 +183,34 @@ def print_help(): print('Adding IP address {0} to known hosts ...'.format(ip_addr)) res = subprocess.run('ssh-keygen -R {}'.format(ip_addr), shell=True) if res.returncode != 0: - print('ERROR when removing server IP from known hosts.\n{0}', res.stderr) + print('ERROR when removing server IP from known hosts.\n {0}'.format(res.stderr)) exit(1) -else: +elif res.stdout is not None: print(res.stdout) res = subprocess.run('ssh-keyscan -T 240 {0} >> ~/.ssh/known_hosts'.format(ip_addr), shell=True) if res.returncode != 0: - print('ERROR when adding server IP to known hosts.\n{0}', res.stderr) + print('ERROR when adding server IP to known hosts.\n {0}'.format(res.stderr)) exit(1) -else: +elif res.stdout is not None: print(res.stdout) # send configuration file to Server -res = subprocess.run( - 'scp {0} rtmpserver@{1}:/home/rtmpserver/rtmp_server_config.json'.format( +scp_cmd = 'scp \'{0}\' rtmpserver@{1}:/home/rtmpserver/rtmp_server_config.json'.format( rtmp_config_filepath, ip_addr - ), + ) +print('Sending configuration file to serverr with: {0}'.format(scp_cmd)) +res = subprocess.run( + scp_cmd, shell=True ) if res.returncode != 0: - print('ERROR when sending RTMP configuration to server.\n{0}', res.stderr) + print( + 'ERROR when sending RTMP configuration to server.\n' + ' returncode = {0}\n stderr = {1}'.format(res.returncode, res.stderr) + ) exit(1) -else: +elif res.stdout is not None: print(res.stdout) # start the docker subprocess