Fix start standalone fail because db not init yet (#8191)
This commit is contained in:
parent
103ccb01da
commit
128ede3ee9
|
|
@ -39,6 +39,8 @@ import javax.annotation.PostConstruct;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
|
@ -53,8 +55,8 @@ public final class AlertPluginManager {
|
|||
this.pluginDao = pluginDao;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void installPlugin() {
|
||||
@EventListener
|
||||
public void installPlugin(ApplicationReadyEvent readyEvent) {
|
||||
final Set<String> names = new HashSet<>();
|
||||
|
||||
ServiceLoader.load(AlertChannelFactory.class).forEach(factory -> {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan("org.apache.dolphinscheduler")
|
||||
|
|
@ -68,8 +70,8 @@ public class AlertServer implements Closeable {
|
|||
SpringApplication.run(AlertServer.class, args);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
@EventListener
|
||||
public void start(ApplicationReadyEvent readyEvent) {
|
||||
logger.info("Starting Alert server");
|
||||
|
||||
checkTable();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class AlertPluginManagerTest extends TestCase {
|
|||
public void testAlertPluginManager() {
|
||||
Mockito.when(pluginDao.addOrUpdatePluginDefine(Mockito.any(PluginDefine.class))).thenReturn(0);
|
||||
|
||||
alertPluginManager.installPlugin();
|
||||
alertPluginManager.installPlugin(null);
|
||||
|
||||
Assert.assertEquals(1, alertPluginManager.size());
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class AlertServerTest extends TestCase {
|
|||
|
||||
Mockito.when(alertConfig.getPort()).thenReturn(50053);
|
||||
|
||||
alertServer.start();
|
||||
alertServer.start(null);
|
||||
|
||||
NettyRemotingServer nettyRemotingServer = Whitebox.getInternalState(alertServer, "server");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue