Browse Source

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
lgcareer 5 years ago
parent
commit
5a13c4cb2d

+ 14 - 4
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();
     }

+ 5 - 0
escheduler-alert/src/main/resources/application_alert.properties

@@ -0,0 +1,5 @@
+logging.config=classpath:alert_logback.xml
+
+# server port
+server.port=7789
+

+ 1 - 1
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