mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
when timezone is +0800, default repo mirror is aliyun. #452
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user