From db588f894c53425a25b29afe26999d75b0d2fe95 Mon Sep 17 00:00:00 2001
From: qkqpttgf <45693631+qkqpttgf@users.noreply.github.com>
Date: Mon, 20 Jan 2020 12:52:22 +0800
Subject: [PATCH] fix:fail to set config. check SCF stat before set.
---
function/scf.php | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/function/scf.php b/function/scf.php
index ac8be30..90a3534 100644
--- a/function/scf.php
+++ b/function/scf.php
@@ -153,7 +153,7 @@ function get_refresh_token()
$tmp['client_id'] = $_POST['client_id'];
$tmp['client_secret'] = $_POST['client_secret'];
}
- $response = setConfig($tmp);
+ $response = json_decode( setConfig($tmp), true )['Response'];
$title = getconstStr('MayinEnv');
$html = getconstStr('Wait') . ' 3s';
if (isset($response['Error'])) {
@@ -161,7 +161,7 @@ function get_refresh_token()
' . $response['Error']['Message'] . '
function_name:' . $_SERVER['function_name'] . '
Region:' . $_SERVER['Region'] . '
-namespace:' . $Namespace . '
+namespace:' . $_SERVER['namespace'] . '
';
$title = 'Error';
}
@@ -183,13 +183,19 @@ namespace:' . $Namespace . '
$tmp['SecretKey'] = $SecretKey;
}
echo SetbaseConfig($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
- $response = updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey);
+ $trynum = 0;
+ while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
+'.++$trynum;
+ //sleep(10);
+ //$stat = json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response'];
+ //echo $stat['Status'].$stat['StatusDesc'];
+ $response = json_decode( updateEnvironment($tmp, $_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey), true)['Response'];
if (isset($response['Error'])) {
$html = $response['Error']['Code'] . '
' . $response['Error']['Message'] . '
function_name:' . $_SERVER['function_name'] . '
Region:' . $_SERVER['Region'] . '
-namespace:' . $Namespace . '
+namespace:' . $_SERVER['namespace'] . '
';
$title = 'Error';
} else {
@@ -445,17 +451,20 @@ namespace:' . $namespace . '
}
$tmp['domain_path'] = $tmparr;
}*/
- $response = setConfig($tmp);
+ $response = json_decode( setConfig($tmp), true )['Response'];
if (isset($response['Error'])) {
$html = $response['Error']['Code'] . '
' . $response['Error']['Message'] . '
function_name:' . $_SERVER['function_name'] . '
Region:' . $_SERVER['Region'] . '
-namespace:' . $Namespace . '
+namespace:' . $_SERVER['namespace'] . '
';
$title = 'Error';
} else {
- sleep(3);
+ $trynum = 0;
+ while( json_decode(getfunctioninfo($_SERVER['function_name'], $_SERVER['Region'], $_SERVER['namespace'], $SecretId, $SecretKey),true)['Response']['Status']!='Active' ) echo '
+'.++$trynum;
+ //sleep(3);
$html .= '';
$title = getconstStr('Setup');
}