Skip to content

Commit

Permalink
Update application-site host/port settings update-mode on start.
Browse files Browse the repository at this point in the history
  • Loading branch information
billchen198318 committed Jun 13, 2016
1 parent f62eaa8 commit fa52dfb
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 2 deletions.
Expand Up @@ -55,3 +55,11 @@ googleMap.clientLocationEnable=N
# =====================================================
twitter.enable=Y


# =====================================================
# config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
# 1 - only first one
# 2 - always update
# =====================================================
base.applicationSiteHostUpdateMode=1

Expand Up @@ -33,6 +33,7 @@
<entry key="googleMap.clientLocationEnable" value="${googleMap.clientLocationEnable}" />
<entry key="twitter.enable" value="${twitter.enable}" />
<entry key="base.loginCaptchaCodeEnable" value="${base.loginCaptchaCodeEnable}" />
<entry key="base.applicationSiteHostUpdateMode" value="${base.applicationSiteHostUpdateMode}" />
</map>
</constructor-arg>
</bean>
Expand Down
Expand Up @@ -30,13 +30,16 @@
import org.apache.commons.lang3.StringUtils;

import com.netsteadfast.greenstep.base.AppContext;
import com.netsteadfast.greenstep.base.Constants;
import com.netsteadfast.greenstep.base.exception.ServiceException;
import com.netsteadfast.greenstep.base.model.DefaultResult;
import com.netsteadfast.greenstep.po.hbm.TbSys;
import com.netsteadfast.greenstep.service.ISysService;
import com.netsteadfast.greenstep.vo.SysVO;

public class ApplicationSiteUtils {
public static final String UPDATE_HOST_ALWAYS = "2";
public static final String UPDATE_HOST_ONLY_FIRST_ONE = "1";
private static Map<String, String> contextPathMap = new HashMap<String, String>();

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -128,7 +131,10 @@ public static String getContextPathFromMap(String sysId) {

@SuppressWarnings("unchecked")
public static void configureHost(String sysId, String logConfFileFullPath) {
if (FSUtils.readStr(logConfFileFullPath).trim().equals("1")) {
String logValue = FSUtils.readStr(logConfFileFullPath).trim();
if (!StringUtils.isBlank(logValue) && UPDATE_HOST_ONLY_FIRST_ONE.equals(Constants.getApplicationSiteHostUpdateMode())) {
// has before start log file, and UPDATE_HOST_ONLY_FIRST_ONE mode
FSUtils.writeStr2(logConfFileFullPath, UPDATE_HOST_ONLY_FIRST_ONE);
return;
}
ISysService<SysVO, TbSys, String> sysService =
Expand All @@ -153,7 +159,14 @@ public static void configureHost(String sysId, String logConfFileFullPath) {
sys.setHost( hostAddress + ":" + port );
}
sysService.updateObject(sys);
FSUtils.writeStr2(logConfFileFullPath, "1");


if (UPDATE_HOST_ALWAYS.equals(Constants.getApplicationSiteHostUpdateMode())) {
FSUtils.writeStr2(logConfFileFullPath, UPDATE_HOST_ALWAYS);
} else {
FSUtils.writeStr2(logConfFileFullPath, UPDATE_HOST_ONLY_FIRST_ONE);
}

} catch (ServiceException e) {
e.printStackTrace();
} catch (Exception e) {
Expand Down
Binary file modified core-export-lib/core-lib.jar
Binary file not shown.
12 changes: 12 additions & 0 deletions core-lib/BASE/com/netsteadfast/greenstep/base/Constants.java
Expand Up @@ -264,4 +264,16 @@ public static String getLoginCaptchaCodeEnable() {
return (String)appSettingsMap.get("base.loginCaptchaCodeEnable");
}

/**
* 是否更新 tb_sys.host 的設定
* config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
* 1 - only first one 只有第一次啟動時, check 有 log 檔案後就不更新了
* 2 - always update 每次都會更新
* @return
*/
public static String getApplicationSiteHostUpdateMode() {
getSettingsMap();
return (String)appSettingsMap.get("base.applicationSiteHostUpdateMode");
}

}
Expand Up @@ -55,3 +55,11 @@ googleMap.clientLocationEnable=N
# =====================================================
twitter.enable=Y


# =====================================================
# config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
# 1 - only first one
# 2 - always update
# =====================================================
base.applicationSiteHostUpdateMode=1

Expand Up @@ -55,3 +55,11 @@ googleMap.clientLocationEnable=N
# =====================================================
twitter.enable=Y


# =====================================================
# config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
# 1 - only first one
# 2 - always update
# =====================================================
base.applicationSiteHostUpdateMode=1

Expand Up @@ -55,3 +55,11 @@ googleMap.clientLocationEnable=N
# =====================================================
twitter.enable=Y


# =====================================================
# config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
# 1 - only first one
# 2 - always update
# =====================================================
base.applicationSiteHostUpdateMode=1

Expand Up @@ -55,3 +55,11 @@ googleMap.clientLocationEnable=N
# =====================================================
twitter.enable=Y


# =====================================================
# config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
# 1 - only first one
# 2 - always update
# =====================================================
base.applicationSiteHostUpdateMode=1

Expand Up @@ -55,3 +55,11 @@ googleMap.clientLocationEnable=N
# =====================================================
twitter.enable=Y


# =====================================================
# config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
# 1 - only first one
# 2 - always update
# =====================================================
base.applicationSiteHostUpdateMode=1

Expand Up @@ -55,3 +55,11 @@ googleMap.clientLocationEnable=N
# =====================================================
twitter.enable=Y


# =====================================================
# config update tb_sys.host when start CORE-WEB,GSBSC-WEB,QCHARTS-WEB
# 1 - only first one
# 2 - always update
# =====================================================
base.applicationSiteHostUpdateMode=1

0 comments on commit fa52dfb

Please sign in to comment.