From 5a13c4cb2d5a2b6ceafef4f852f20a2907b516a0 Mon Sep 17 00:00:00 2001 From: lgcareer <18610854716@163.com> Date: Tue, 24 Sep 2019 16:43:13 +0800 Subject: [PATCH] add spring boot on alert server (#872) * Remove useless dependencies and add jsp-2.1-6.1.14 * Determine if principal is empty in getJdbcUrl method * fix bug when register worker but create master node in zookeeper * Remove useless dependencies such as hive-shims and log4j * upgrade commons-email from 1.2 to 1.5 and remove mail-1.4.5.jar * add support for postgresql in upgrade database * add support for postgresql in upgrade database * update mysql in upgrade from 1.1.0 to next version * add table name change ddl * add spring boot on alert server --- .../java/cn/escheduler/alert/AlertServer.java | 18 ++++++++++++++---- .../resources/application_alert.properties | 5 +++++ script/escheduler-daemon.sh | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 escheduler-alert/src/main/resources/application_alert.properties diff --git a/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java b/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java index 27c5f0ce56..b8402aacf1 100644 --- a/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java +++ b/escheduler-alert/src/main/java/cn/escheduler/alert/AlertServer.java @@ -20,28 +20,33 @@ import cn.escheduler.alert.runner.AlertSender; import cn.escheduler.alert.utils.Constants; import cn.escheduler.common.thread.Stopper; import cn.escheduler.dao.AlertDao; -import cn.escheduler.dao.DaoFactory; import cn.escheduler.dao.model.Alert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.context.annotation.ComponentScan; import java.util.List; /** * alert of start */ -public class AlertServer { +@ComponentScan("cn.escheduler") +public class AlertServer implements CommandLineRunner { private static final Logger logger = LoggerFactory.getLogger(AlertServer.class); /** * Alert Dao */ - private AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class); + @Autowired + private AlertDao alertDao; private AlertSender alertSender; private static volatile AlertServer instance; - private AlertServer() { + public AlertServer() { } @@ -72,7 +77,12 @@ public class AlertServer { public static void main(String[] args){ + SpringApplication app = new SpringApplication(AlertServer.class); + app.run(args); + } + @Override + public void run(String... strings) throws Exception { AlertServer alertServer = AlertServer.getInstance(); alertServer.start(); } diff --git a/escheduler-alert/src/main/resources/application_alert.properties b/escheduler-alert/src/main/resources/application_alert.properties new file mode 100644 index 0000000000..cbc81b06e6 --- /dev/null +++ b/escheduler-alert/src/main/resources/application_alert.properties @@ -0,0 +1,5 @@ +logging.config=classpath:alert_logback.xml + +# server port +server.port=7789 + diff --git a/script/escheduler-daemon.sh b/script/escheduler-daemon.sh index d54272c886..bb075f7aa8 100644 --- a/script/escheduler-daemon.sh +++ b/script/escheduler-daemon.sh @@ -50,7 +50,7 @@ elif [ "$command" = "worker-server" ]; then LOG_FILE="-Dspring.config.location=conf/application_worker.properties -Ddruid.mysql.usePingMethod=false" CLASS=cn.escheduler.server.worker.WorkerServer elif [ "$command" = "alert-server" ]; then - LOG_FILE="-Dlogback.configurationFile=conf/alert_logback.xml" + LOG_FILE="-Dspring.config.location=conf/application_alert.properties -Ddruid.mysql.usePingMethod=false" CLASS=cn.escheduler.alert.AlertServer elif [ "$command" = "logger-server" ]; then CLASS=cn.escheduler.server.rpc.LoggerServer