when timezone is +0800, default repo mirror is aliyun. #452

pull/470/head
hengyunabc 6 years ago
parent 5c857d045a
commit 64439540bb

@ -42,7 +42,7 @@ SESSION_TIMEOUT=300
USE_VERSION=
# maven repo to download arthas
REPO_MIRROR="center"
REPO_MIRROR=
# use http to download arthas
USE_HTTP=false
@ -580,6 +580,13 @@ parse_arguments()
fi
fi
if [ -z ${REPO_MIRROR} ]; then
REPO_MIRROR="center"
# if timezone is +0800, set REPO_MIRROR to aliyun
if [[ -x "$(command -v date)" ]] && [[ $(date +%z) == "+0800" ]]; then
REPO_MIRROR="aliyun"
fi
fi
# check pid
if [ -z ${TARGET_PID} ] && [ ${BATCH_MODE} = false ]; then

@ -11,6 +11,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.InputMismatchException;
@ -88,9 +90,9 @@ public class Bootstrap {
private boolean versions;
/**
* download from maven center repository by default
* download from maven repository. if timezone is +0800, default value is 'aliyun', else is 'center'.
*/
private String repoMirror = "center";
private String repoMirror;
/**
* enforce use http to download arthas. default use https
@ -226,6 +228,15 @@ public class Bootstrap {
System.exit(0);
}
if (bootstrap.getRepoMirror() == null || bootstrap.getRepoMirror().trim().isEmpty()) {
bootstrap.setRepoMirror("center");
// if timezone is +0800, default repo mirror is aliyun
if (TimeUnit.MILLISECONDS.toHours(TimeZone.getDefault().getOffset(System.currentTimeMillis())) == 8) {
bootstrap.setRepoMirror("aliyun");
}
}
AnsiLog.debug("Repo mirror:" + bootstrap.getRepoMirror());
if (bootstrap.isVersions()) {
if (mavenMetaData == null) {
mavenMetaData = DownloadUtils.readMavenMetaData(bootstrap.getRepoMirror(), bootstrap.isuseHttp());

Loading…
Cancel
Save