Skip to content

Commit

Permalink
feat: 支持模块启动时通过传递env参数动态指定模块的启动类 (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
liufeng-xiwo committed Nov 14, 2024
1 parent 7ab39b4 commit dc93ed7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ public void start(String[] args, Map<String, String> envs) throws Throwable {

private void doStart(String[] args, Map<String, String> envs) throws Throwable {
AssertUtils.isTrue(bizState == BizState.RESOLVED, "BizState must be RESOLVED");

// 支持运行时根据环境变量动态设置模块的启动类
if (envs != null){
String mainClassFromEnv = envs.get(Constants.BIZ_MAIN_CLASS);
if (mainClassFromEnv != null){
mainClass = mainClassFromEnv;
ArkLoggerFactory.getDefaultLogger().info("Ark biz {} will start with main class {} from envs", getIdentity(), mainClassFromEnv);
}
}

if (mainClass == null) {
throw new ArkRuntimeException(String.format("biz: %s has no main method", getBizName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public class Constants {

public final static String EMBED_STATIC_BIZ_IN_RESOURCE_ENABLE = "sofa.ark.embed.static.biz.in.resource.enable";
public final static String ACTIVATE_NEW_MODULE = "activate.new.module";
public final static String BIZ_MAIN_CLASS = "sofa.ark.biz.main.class";

/**
* uninstall the biz if it starts up failed
Expand Down

0 comments on commit dc93ed7

Please sign in to comment.